#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formatting

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Formatting

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
condionally formatting based on another cells formatting? Derrick Excel Discussion (Misc queries) 2 July 31st 09 08:05 PM
Formatting Conditional Formatting Icon Sets The Rook[_2_] Excel Discussion (Misc queries) 3 March 7th 09 08:48 PM
Protect Cell Formatting including Conditional Formatting Mick Jennings Excel Discussion (Misc queries) 5 November 13th 07 05:32 PM
conditional Formatting based on cell formatting Totom Excel Worksheet Functions 3 January 20th 07 02:02 PM
expanding custom formatting without removing existing cell formatting? Keith Excel Worksheet Functions 3 December 27th 06 01:54 PM


All times are GMT +1. The time now is 03:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"