Using VBA Code to apply Currency Format?

mynamesjason

New Member
Joined
Aug 5, 2008
Messages
35
Here's the scenario in Excel 2003:

I have a list validation in cell B86 to force the user to either choose USD or JPY. What I would like to happen is when the user chooses a currency, it will apply a Currency format to have 0 decimal places and the appropriate currency symbol.

Any ideas?

Thanks.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
You didn't mention where you want to format so this example just formats A86 whenever the value in B86 changes. You can change that to format whatever you want.

Right click the sheet tab and choose View Code. Paste this in the sheet module:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$B$86" Then Exit Sub
Select Case Target.Value
  Case "USD"
    Range("A86").NumberFormat = "$#,##0"
  Case "JPY"
    Range("A86").NumberFormat = "[$¥-2] #,##0"
End Select
End Sub

Hit Alt+Q to close the vb editor, enter a numeric value in A86 and try a change from your validation list in B86.

Hope it helps.
 
Upvote 0
See if this works for you;
Code:
Sub YEN()
 
    Range("B86").Select
    Selection.NumberFormat = "[$¥] #,##0"
 
End Sub
 
Sub USD()
 
    Range("B86").Select
    Selection.NumberFormat = "[$$-409]#,##0"
 
End Sub

HTH
Colin
 
Upvote 0

Forum statistics

Threads
1,225,563
Messages
6,185,701
Members
453,315
Latest member
funktgf

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top