Mark,
Maybe like this, to change specific cells:
Sub ChangeCurrFormat()
Dim rngCurrency As Range
Dim MyMsg As String
Dim myStyle As Integer
Set rngCurrency = Range("A1,B3,C5,D7")
MyMsg = "1: US Dollars = > $100.00" & Chr(10) & _
"2: UK Pounds = > £100.00" & Chr(10) & _
"3: EU Euros = > ?100.00" & Chr(10) & Chr(10) & _
"Choose a style: 1, 2, or 3...."
myStyle = Application.InputBox(MyMsg, "Style Choice", , , , , , 1)
Select Case myStyle
Case 1: rngCurrency.NumberFormat = "$#,##0.00"
Case 2: rngCurrency.NumberFormat = "[$£-809]#,##0.00"
Case 3: rngCurrency.NumberFormat = "[$?-2] #,##0.00"
End Select
End Sub
Or, to change all currency cells (once you've set the formatting):
Sub ChangeCurrFormatAllCells()
Dim rngCurrency As Range
Dim MyMsg As String
Dim myStyle As Integer
Dim myCell As Range
MyMsg = "1: US Dollars = > $100.00" & Chr(10) & _
"2: UK Pounds = > £100.00" & Chr(10) & _
"3: EU Euros = > ?100.00" & Chr(10) & Chr(10) & _
"Choose a style: 1, 2, or 3...."
myStyle = Application.InputBox(MyMsg, "Style Choice", , , , , , 1)
For Each myCell In ActiveSheet.UsedRange
Select Case myStyle
Case 1: If InStr(1, myCell.NumberFormat, "£") > 0 Or _
InStr(1, myCell.NumberFormat, "?") > 0 Then _
myCell.NumberFormat = "$#,##0.00"
Case 2: If InStr(1, myCell.NumberFormat, "$#") > 0 Or _
InStr(1, myCell.NumberFormat, "?") > 0 Then _
myCell.NumberFormat = "[$£-809]#,##0.00"
Case 3: If InStr(1, myCell.NumberFormat, "$#") > 0 Or _
InStr(1, myCell.NumberFormat, "£") > 0 Then _
myCell.NumberFormat = "[$?-2] #,##0.00"
End Select
Next myCell
End Sub
Note that these macros don't conver the values from one currency to the other, but just change the
formatting.
HTH,
Bernie
MS Excel MVP
I have a spreadsheet which I plan to protect all but a handful of
fields for the user to enter various money amounts. I'd like to include
a BUTTON in the spreadsheet that will force the display of any money
field to pounds, dollars, or euro. Mostly a cosmetic change, and I
don't want the user to have to select the fields to change since some
are locked.
Is there any example like this using a button/macro?