View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach
 
Posts: n/a
Default Set number format based on cell contents

You need VBA for that. Paste the following macro into the sheet module for
the sheet you are working on. To do that, right-click on the sheet tab,
select View Code, and paste this macro into that module.
Note that this macro does exactly what you asked. That is, it will change
the format of C3 if you select $ or % in B3. If you want this to work on
other cells, you will need to alter the macro.
Note that the macro uses $ instead of the British pound symbol. You need to
change that.
Post back if you need more. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "B3" Then
If Target = "$" Then
Target.Offset(, 1).NumberFormat = "$#,##0.00"
Else
Target.Offset(, 1).NumberFormat = "General"
End If
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
End Sub
"nospaminlich" wrote in message
...
I have a cell B3 which shows a Data Validation list of £ or %

Having selected £ or % in B3 the user then enters a number in C3. I want
to
have cell C3 formatted to General if B3 = % and formatted to Currency if
B3 =
£.

I'd really appreciate some help

Thanks