Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default formatting macro with a toggle button

Hi -

I am trying to change the formatting of a group of cells with a toggle
button, but the cells to not format to accounting when the toggle
button is clicked. Is there something I can add to this?

Here is what I have so far -
Cells M62:AJ64 are the cells that I would like to have the formatting
changed. Cell CC60 is the linked cell of the toggle button that
changes from TRUE to FALSE. I can't seem to get the formatting to
change when the value is TRUE.

Range("M62:AJ64").Select
With Selection
If .Cells(cc60) = False Then
Selection.NumberFormat = "0.00%"
Else
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($*
""-""??_);_(@_)"
End If
End With

Thanks.
STephen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default formatting macro with a toggle button

On 25 Jan 2004 00:25:53 -0800, (Stephen) wrote:

Hi -

I am trying to change the formatting of a group of cells with a toggle
button, but the cells to not format to accounting when the toggle
button is clicked. Is there something I can add to this?

Here is what I have so far -
Cells M62:AJ64 are the cells that I would like to have the formatting
changed. Cell CC60 is the linked cell of the toggle button that
changes from TRUE to FALSE. I can't seem to get the formatting to
change when the value is TRUE.

Range("M62:AJ64").Select
With Selection


There are three problems on the next line. First, CC60 isn't part of
the "Selection" and therefore shouldn't have a dot operator in front
of it.

Second, cc60 is going to be interpreted as a variable. Third, the
arguments for Cells should be row and column indexes.

I also encountered a problem with your second number format.

If .Cells(cc60) = False Then
Selection.NumberFormat = "0.00%"
Else
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($*
""-""??_);_(@_)"
End If
End With


This, however, worked for me:

Private Sub ToggleButton1_Click()

Range("M62:AJ64").Select

With Selection

'Use Range instead of Cells.
If Range("CC60") = False Then

Selection.NumberFormat = "0.00%"

Else

Selection.NumberFormat = _
"_($* #,##0.00_);_($* (#,##0.00);_($*-??_);_(@_)"

End If
End With

End Sub

Note: Strictly speaking there is no need to select the range before
applying the formatting, but I assumed that you want the user to see
it change.

---------------------------------------------------------
Hank Scorpio
- Yes, yes, I know I've been missing for a while. Long story. And don't
ask what the size of my inbox is at the moment either... 8^
scorpionet who hates spam is at iprimus.com.au (You know what to do.)
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default formatting macro with a toggle button

Stephen,

Cell CC60 is not within your selection so you don't need the full stop
before it.
Also, it's the Value of the toggle button that you need.

Try
If Cells(CC60).Value = False Then

HTH
Henry



"Stephen" wrote in message
om...
Hi -

I am trying to change the formatting of a group of cells with a toggle
button, but the cells to not format to accounting when the toggle
button is clicked. Is there something I can add to this?

Here is what I have so far -
Cells M62:AJ64 are the cells that I would like to have the formatting
changed. Cell CC60 is the linked cell of the toggle button that
changes from TRUE to FALSE. I can't seem to get the formatting to
change when the value is TRUE.

Range("M62:AJ64").Select
With Selection
If .Cells(cc60) = False Then
Selection.NumberFormat = "0.00%"
Else
Selection.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($*
""-""??_);_(@_)"
End If
End With

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
Toggle Button Squeaky Excel Worksheet Functions 0 September 17th 08 04:14 PM
Need to Use 1 Button to toggle On or Off Jim May Excel Discussion (Misc queries) 2 December 1st 07 08:01 PM
Toggle button keithl816 Excel Discussion (Misc queries) 2 November 21st 05 09:16 PM
Toggle Button Dave_2k5 Excel Discussion (Misc queries) 2 September 1st 05 11:27 AM
Toggle Button Ben E[_2_] Excel Programming 1 October 29th 03 04:42 PM


All times are GMT +1. The time now is 08:11 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"