Conditional number format of cell

B

bsteg

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
 
T

Tom Ogilvy

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.
 
D

Don Guillett

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top