Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Change cell formatting based on contents of another cell 1

Status
Not open for further replies.

maxxheight

IS-IT--Management
Jun 17, 2004
43
0
0
US
I have an Excel spreadsheet with a cell(A90) that offers the choice of choosing A, B, or C. If the user chooses A or B, then the number in cell P90 should be a percentage, but if the user chooses the C value for A90, then the format of cell P90 needs to be in Dollars. I tried using conditional formatting, but that only allows you to change colors and font.

Wondering if anyone has an idea on how to do this.

Thanks

Mark
 
Mark,

Can't be done with native worksheet functionality.

However, CAN be done with VBA code. Copy 'n' paste in the SHEET Object (right click the sheet tab)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   Dim rng
   With Target
      Set rng = Application.Intersect(Target, Range("A:A"))
      If Not rng Is Nothing Then
         Select Case .Value
            Case "A", "B"
               Cells(.Row, "P").NumberFormat = "0%"
            Case "C"
               Cells(.Row, "P").Style = "Currency"
         End Select
      End If
   End With
End Sub

Skip,
[sub]
[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue][/sub]
 
Thanks a million.

I will give it a shot today and see how it works out.

Have a great day.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top