Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Toggle Switch

Bob gave me the following macro to switch from calculation auto to
calculation manual and works just fine. What I would like to next is to
change the color of the button from Red if manual to Green if automatic. Can
do?


Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Toggle Switch

You'll need to know the name of your command button. The code below is
using "CommandButton3".

Sub ToggleCalculation()

If Application.Calculation = xlCalculationManual _
Then
With ActiveSheet.OLEObjects("CommandButton3").Object
.BackColor = &HFF00&
.Caption = "Auto"
.ForeColor = &H0&
End With
Application.Calculation = xlCalculationAutomatic
Else
With ActiveSheet.OLEObjects("CommandButton3").Object
.BackColor = &HFF&
.Caption = "Manual"
.ForeColor = &HFFFFFF
End With
Application.Calculation = xlCalculationManual
End If
End Sub


HTH,
Paul

"Beep Beep" wrote in message
...
Bob gave me the following macro to switch from calculation auto to
calculation manual and works just fine. What I would like to next is to
change the color of the button from Red if manual to Green if automatic.
Can
do?


Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default Toggle Switch

What kind of button - control toolbox, or forms ?

Tim


"Beep Beep" wrote in message
...
Bob gave me the following macro to switch from calculation auto to
calculation manual and works just fine. What I would like to next is to
change the color of the button from Red if manual to Green if automatic.
Can
do?


Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Toggle Switch

Custom Button with a smiley face on the toolbar

"Tim" wrote:

What kind of button - control toolbox, or forms ?

Tim


"Beep Beep" wrote in message
...
Bob gave me the following macro to switch from calculation auto to
calculation manual and works just fine. What I would like to next is to
change the color of the button from Red if manual to Green if automatic.
Can
do?


Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Toggle Switch

It is impossible to see from your code what kind of cutton you are talking
about.

If from the forms toolbar, then no.

Why not use a toggle button from the control toolbox toolbar and then you
shouldn't have to change the color.

--
Regards,
Tom Ogilvy



"Beep Beep" wrote:

Bob gave me the following macro to switch from calculation auto to
calculation manual and works just fine. What I would like to next is to
change the color of the button from Red if manual to Green if automatic. Can
do?


Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Toggle Switch

Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub


All of the above subroutine's code can be replaced with this single line...

Sub ToggleCalculation()
Application.Calculation = (xlCalculationManual + xlCalculationAutomatic) - Application.Calculation
End Sub

Rick
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Toggle Switch

Thanks Rich, however I am trying to determine if I can have the button on the
toolbar (custom button) to change colors when the calculation changes from
manual to automatic or vice versus.

"Rick Rothstein (MVP - VB)" wrote:

Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub


All of the above subroutine's code can be replaced with this single line...

Sub ToggleCalculation()
Application.Calculation = (xlCalculationManual + xlCalculationAutomatic) - Application.Calculation
End Sub

Rick

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Toggle Switch

No you can't. You might want to change the icon on the button.
--
Regards,
Tom Ogilvy


"Beep Beep" wrote:

Thanks Rich, however I am trying to determine if I can have the button on the
toolbar (custom button) to change colors when the calculation changes from
manual to automatic or vice versus.

"Rick Rothstein (MVP - VB)" wrote:

Sub ToggleCalculation()
With Application
If .Calculation = xlCalculationManual Then
.Calculation = xlCalculationAutomatic
Else
.Calculation = xlCalculationManual
End If
End With
End Sub


All of the above subroutine's code can be replaced with this single line...

Sub ToggleCalculation()
Application.Calculation = (xlCalculationManual + xlCalculationAutomatic) - Application.Calculation
End Sub

Rick

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
Linking a cell to a toggle switch Brisbane Rob[_4_] Excel Programming 2 October 29th 05 12:41 AM
Toggle switch between absolute and relative values creating a macr Al Excel Discussion (Misc queries) 4 September 29th 05 08:15 PM
Toggle on/off switch for x-y graph Brad Charts and Charting in Excel 4 August 19th 05 03:08 AM
how to quickly toggle or switch to next worksheet Kwong Yau Leung Excel Worksheet Functions 3 May 9th 05 10:33 AM
How to toggle Cesar Zapata[_2_] Excel Programming 3 November 15th 03 01:13 AM


All times are GMT +1. The time now is 06:57 PM.

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"