Code:
Sub ChangeCurrency()' ChangeCurrency Macro
' Programmed by Lucas on 10/31/16
Dim NewCurrency, OldCurrency As String
NewCurrency = Range("currency_flag").Value
OldCurrency = "USD"
Sheets.Select
Select Case OldCurrency & "_" & NewCurrency
Case "USD_GBP"
Call USD_GBP
Case Else
MsgBox "Selected currency must be changed manually.", 0, "Error: Select a Different Currency"
End Select
End Sub
Sub USD_GBP()
'accounting w/o decimals
Application.FindFormat.NumberFormat = "_($* #,##0_);_($* (#,##0);_($* ""-""_);_(@_)"
Application.ReplaceFormat.NumberFormat = "_-[$£-809]* #,##0_-;-[$£-809]* #,##0_-;_-[$£-809]* ""-""_-;_-@_-"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True
'accounting w/ decimals
Application.FindFormat.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)"
Application.ReplaceFormat.NumberFormat = "_-[$£-809]* #,##0.00_-;-[$£-809]* #,##0.00_-;_-[$£-809]* ""-""??_-;_-@_-"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True
'currency w/ decimals
Application.FindFormat.NumberFormat = "$#,##0.00_);($#,##0.00)"
Application.ReplaceFormat.NumberFormat = "[$£-809]#,##0.00;-[$£-809]#,##0.00"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True
'currency w/o decimals
Application.FindFormat.NumberFormat = "$#,##0_);($#,##0)"
Application.ReplaceFormat.NumberFormat = "[$£-809]#,##0"
Cells.Replace What:="", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=True, ReplaceFormat:=True
'currency in text formulae
Cells.Replace What:=",""$", Replacement:=",""£", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=True
End Sub
I wrote the above code to replace all USD formats with GBP formats (the USD_GBP sub does this)
However, I'm wondering what's the most efficient way to make this change across all sheets in the workbook.
I've tried sheets.select but it says "Method of Object Sheets Failed"
Also considered a for loop as in for each ws in activeworkbook.sheets call the sub and then next ws
but that seems inefficient
less important but also would appreciate any ideas on efficiently changing between currencies. i'm thinking right now to change from say GBP to EUR i'd have to reset the currency to dollars and then set the currencies to EUR.
The currencies I'll have are CAD, EUR, GBP, USD, maybe one or two others, seems a huge number of subs to program each switch
Appreciate the help
Last edited: