Conditional number format of cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to conditionally change the number format of a cell. For example, if cell A1 = '%' , I want the format of the number in cell A2 to have a percentage format or if A1 = '$' I want the number in cell A2 to have a currency format. I understand how to use conditional formatting but I don't see how to change the number format, just the font, border or pattern.

Thanks in advance.

Brad
 
Those are the options. You would need a macro to do this.

Changing the format, however, does not trigger an event, so you would
probably need the selectionchange event.

Just check the numberformat property and make the appropriate change.

--
Regards,
Tom Ogilvy

bsteg said:
I want to conditionally change the number format of a cell. For example,
if cell A1 = '%' , I want the format of the number in cell A2 to have a
percentage format or if A1 = '$' I want the number in cell A2 to have a
currency format. I understand how to use conditional formatting but I don't
see how to change the number format, just the font, border or pattern.
 
try

Sub copystyle()
If Range("j7").Style = "Percent" Then _
Range("k7").Style = "Percent"
If Range("j8").Style = "Currency" Then _
Range("k8").Style = "Currency"
End Sub

bsteg said:
I want to conditionally change the number format of a cell. For example,
if cell A1 = '%' , I want the format of the number in cell A2 to have a
percentage format or if A1 = '$' I want the number in cell A2 to have a
currency format. I understand how to use conditional formatting but I don't
see how to change the number format, just the font, border or pattern.
 
Back
Top