ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Conditional number format of cell (https://www.excelbanter.com/excel-programming/280680-conditional-number-format-cell.html)

bsteg

Conditional number format of cell
 
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

Tom Ogilvy

Conditional number format of cell
 
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" wrote in message
...
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




Don Guillett[_4_]

Conditional number format of cell
 
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" wrote in message
...
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





All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com