ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Toggling display (https://www.excelbanter.com/excel-programming/431463-toggling-display.html)

Tom

Toggling display
 
Hi,

Cell B5 is named "status". I'm looking for a macro to be attached to a
button. When I click the button once, it shows the word, "On". Clicking it
again it now shows the word "Off", and continues to toggle. Any help ?

TIA
Tom



FSt1

Toggling display
 
hi
what kind of button? Command button on the sheet?

Private Sub CommandButton1_Click()
If Range("B5").Value = "On" Then
Range("B5").Value = "Off"
Else
Range("B5").Value = "On"
End If
End Sub

regards
FSt1

"Tom" wrote:

Hi,

Cell B5 is named "status". I'm looking for a macro to be attached to a
button. When I click the button once, it shows the word, "On". Clicking it
again it now shows the word "Off", and continues to toggle. Any help ?

TIA
Tom




Don Guillett

Toggling display
 
Here is one I did a long time ago. Create a shape and NAME it toggleit

Sub chgtextontoggleit()
ActiveSheet.Shapes("toggleit").Select
With Selection
If .Characters.Text = "ON" Then
msg = "OFF"
Else
msg = "ON"
End If
..Characters.Text = msg
End With
Range("a1").Select
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Tom" wrote in message
...
Hi,

Cell B5 is named "status". I'm looking for a macro to be attached to a
button. When I click the button once, it shows the word, "On". Clicking it
again it now shows the word "Off", and continues to toggle. Any help ?

TIA
Tom




Tom

Toggling display
 
Your efforts are much appreciated Don Guillett and FSt1 once again.

Regards,
Tom


"Tom" wrote in message
...
Hi,

Cell B5 is named "status". I'm looking for a macro to be attached to a
button. When I click the button once, it shows the word, "On". Clicking it
again it now shows the word "Off", and continues to toggle. Any help ?

TIA
Tom






All times are GMT +1. The time now is 09:22 PM.

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