Page 1 of 1

Convert an Excel Formula into FastKey?

Posted: Dec 3rd, ’20, 20:51
by DVT
Can someone help me convert this into Fast Key? I want to be able to use the input macro and only enter the sale price, mortgage price, and auto-populate the sentence. Also is there a way to auto add a comma on numbers once it exceeds 999? For example, "1000" becomes "1,000".

Excel
Image

Formula
Image

Thanks!

Re: Convert an Excel Formula into FastKey?

Posted: Dec 4th, ’20, 12:04
by Marko
Try using "Insert command code" macro, as shown in my other post.
For example, the command code could be

Code: Select all

Send, % ThousandsSep(INPUT__Price * INPUT__Volume)

ThousandsSep(x, s=",") {
	return RegExReplace(x, "\G\d+?(?=(\d{3})+(?:\D|$))", "$0" s)
}
return
In such case use No output prefix "_" before the variable names ("_Price") to instruct FastKeys not to output the value.

Re: Convert an Excel Formula into FastKey?

Posted: Dec 4th, ’20, 21:52
by DVT
That's not working and I am struggling to get this to work. Can you show me using the formula above? That would be most helpful.

Re: Convert an Excel Formula into FastKey?

Posted: Dec 5th, ’20, 11:24
by Marko
The command (Type: Send) would look like this:
%INPUT__SalePrice%%INPUT__MortgagePrice%%CODE_Output%
Note the "_" prefix in front of the variable names (no output).

Use "Insert Command Code" macro with the following code:

Code: Select all

DownPayment := INPUT__SalePrice - INPUT__MortgagePrice
DownPercent := Round((DownPayment/INPUT__SalePrice)*100, 0)
DownPaymentFormat := Thousands(DownPayment)

Send, % "The buyer placed a down payment of $" DownPaymentFormat " (" DownPercent "%) and financed the remaining balance."


Thousands(x, s=",") {
	return RegExReplace(x, "\G\d+?(?=(\d{3})+(?:\D|$))", "$0" s)
}
return

Re: Convert an Excel Formula into FastKey?

Posted: Dec 6th, ’20, 10:50
by DVT
Holy smokes, this works! Thank you so much Marko!