Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi -
Is it possible to add a macro to a toggle button to change the formatting of a group of cells? Currently, depending on whether the toggle button is clicked, the cell will show a dollar value or a percentage and I want the formatting to change from Accounting to Percentage to reflect the data. Example - - When the button is not clicked, the value of cell A1 is 100 and should be formatted $100. - When the button is clicked, the value of cell A1 is .30 and should be formatted 30%. Any help would be greatly appreciated. Thanks. Stephen |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Stephen,
You refer to a group of cells and then to "the cell" so I'm unclear, but this might help. Assign this macro to a button from the forms toolbar, and it will toggle selected cells back and forth. If the cells in the selection start out with different values it will set them all the same on the first toggle. The selected cells don't have to be contiguous: Sub test() With Selection If .Cells(1).Value = 100 Then .Value = 0.3 .NumberFormat = "0%" Else .Value = 100 .NumberFormat = "_($* #,##0_);_($* (#,##0);_($* ""-""_);_(@_)" End If End With End Sub hth, Doug "Stephen" wrote in message m... Hi - Is it possible to add a macro to a toggle button to change the formatting of a group of cells? Currently, depending on whether the toggle button is clicked, the cell will show a dollar value or a percentage and I want the formatting to change from Accounting to Percentage to reflect the data. Example - - When the button is not clicked, the value of cell A1 is 100 and should be formatted $100. - When the button is clicked, the value of cell A1 is .30 and should be formatted 30%. Any help would be greatly appreciated. Thanks. Stephen |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
condionally formatting based on another cells formatting? | Excel Discussion (Misc queries) | |||
Formatting Conditional Formatting Icon Sets | Excel Discussion (Misc queries) | |||
Protect Cell Formatting including Conditional Formatting | Excel Discussion (Misc queries) | |||
conditional Formatting based on cell formatting | Excel Worksheet Functions | |||
expanding custom formatting without removing existing cell formatting? | Excel Worksheet Functions |