2003 Conditional Number Format Help

F00

New Member
Joined
Nov 10, 2008
Messages
8
This site is great and I appreciate all the help everyone offers. Need help with something here.

I'm currently using version 2003 and need help with Number Formatting based on a drop-down choice. I'm not VBA savvy at all so I need some help.

Here is the situation:

Cell F2 contains a drop down with two choices: "$ Dollar" and "% Percent"

If the user chooses "$ Dollar" I need a currency (two decimals) format for the following cell ranges:

H2:H82, J2:J82, L2:L82, N2:N82, P2:P82, R2:R82, T2:T82, V2:V82, X2:X82, Z2:Z82, AB2:AB82, AD2:AD82, AF2:AF82, AH2:AH82

If the user chooses "% Percent" I need a percentage format (one decimal) for the following cell ranges:

H2:H82, J2:J82, L2:L82, N2:N82, P2:P82, R2:R82, T2:T82, V2:V82, X2:X82, Z2:Z82, AB2:AB82, AD2:AD82, AF2:AF82, AH2:AH82

One last detail is that this is a form that starts blank and I'd like the user to be able to make the choice in the drop-down and then type in the number in the cell ranges listed above. Thanks!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try something like this to get you started:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Fmt As String

If Not Intersect(Target, Range("F2")) Is Nothing Then

    Select Case Target
    Case "Dollar"
        Fmt = "$0.00"
    Case "Percent"
        Fmt = "0.0%"
    Case Else
        Fmt = "General"
    End Select
    
    Range("H2:H12,J2:J12").NumberFormat = Fmt
    
End If

End Sub

To make this work, right-clcik on your sheet tab, click View Code, paste this code into the code window. Press Alt+Q to return to Excel and it should work when you change the value in F2.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,792
Members
449,468
Latest member
AGreen17

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