Convert an Excel Formula into FastKey?

Discussion, questions and support.
Post Reply
DVT
Posts: 9
Joined: May 6th, ’20, 18:13

Post by DVT » Dec 3rd, ’20, 20:51

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!
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Dec 4th, ’20, 12:04

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.
DVT
Posts: 9
Joined: May 6th, ’20, 18:13

Post by DVT » Dec 4th, ’20, 21:52

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.
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Dec 5th, ’20, 11:24

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
DVT
Posts: 9
Joined: May 6th, ’20, 18:13

Post by DVT » Dec 6th, ’20, 10:50

Holy smokes, this works! Thank you so much Marko!
Post Reply