Excel form controlsHack 19
=IF function
business case
currency format
data visualization
Excel model
excel vba
toggle buttons
How to Build a Currency Toggle in an Excel Financial Model
Excel Hack #19
14 views
3 min read
2016-09-28
Imagine you have built a business case for a client that wants to easily see the revenue-cost implications in both local and foreign currencies. The following macro - attached to a form control (eithe...
Imagine you have built a business case for a client that wants to easily see the revenue-cost implications in both local and foreign currencies. The following macro - attached to a form control (either button or option button) can automate this task, and free both you and your client from resorting to calculators and currency converters during this process.
The currency toggle macro will accomplish 2 things:
By using cell styles, you can decide the appropriate currency cell format, change font color, font style, cell color and other variables as you deem fit. In my example above, the final cell styles look like this:
After this is done, the macros above will be updated to reflect a command to change the cell styles in all the impacted cells (Range $A$3 to $J$10 in my example) as well:

- multiply all the impacted values by the indicated currency factor
- change the cell format to reflect the selected currency
- creating a macro that multiplies all the values in the relevant cells by the currency factor, or
- entering the currency factor in an Assumptions cell ($C$1), and ensuring all the relevant cells are connected to it throughout the process of building the model.
=IF($AB$1=1,A2+B2, IF($AB$1=2,(A2+B2)*$C$1,0))(the italicized values will be replaced with the appropriate formula or value based on your model) Thus the macro to change currency to USD (dollar) will be this simple code in a module (use shortcut Alt+F11 to open Visual Basic Editor, select Insert > Module):
Sub DollarCurr() Range("AB1").value = 1 End SubAnd the one to change currency to NGN (naira) will be this:
Sub NairaCurr() Range("AB1").value = 2 End SubTo change the cell format to reflect the selected currency, first program the desired cell formats using Cell Styles (Cell Style > New Cell Style).
By using cell styles, you can decide the appropriate currency cell format, change font color, font style, cell color and other variables as you deem fit. In my example above, the final cell styles look like this:
After this is done, the macros above will be updated to reflect a command to change the cell styles in all the impacted cells (Range $A$3 to $J$10 in my example) as well:
Sub DollarCurr() Range(" AB1").Value = 1 Range("A3:J10").Style = "Dollar currency" End SubAnd the one to change currency to NGN (naira) will be this:
Sub NairaCurr() Range("AB1").Value = 2 Range("A3:J10").Style = "Naira currency" End SubTo interact with these macros in the main sheet, you can either use option buttons or simple buttons (Developer > Insert > Form Control > Button, then right-click the created form control to Assign Macro to the appropriate code).
