Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Help with toggling display
Hi,
I have a cell which has a defined name "status". It currently displays the word, "Off". On clicking a button I want it to toggle from "Off" to "On" and vice versa. Any help is much appreciated. TIA Tom |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Help with toggling display
Tom wrote:
Hi, I have a cell which has a defined name "status". It currently displays the word, "Off". On clicking a button I want it to toggle from "Off" to "On" and vice versa. Any help is much appreciated. TIA Tom Add a VB command button to the worksheet (accessible from the Visual Basic toolbar's toolbox). (This is not the same as a Form button -- you can use that as well but the steps are a little different.) With the worksheet in design mode (should be already), double click the new button to reveal the empty sub: Private Sub CommandButton1_Click() Add this code: Private Sub CommandButton1_Click() If Range("Status").Value = "On" Then Range("Status").Value = "Off" ElseIf Range("Status").Value = "Off" Then Range("Status").Value = "On" End If End Sub Return to the worksheet, turn off design mode (the triangle/ruler/pencil widget) and try out your new button. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Help with toggling display
That was great. Thanks smartin.
"smartin" wrote in message ... Tom wrote: Hi, I have a cell which has a defined name "status". It currently displays the word, "Off". On clicking a button I want it to toggle from "Off" to "On" and vice versa. Any help is much appreciated. TIA Tom Add a VB command button to the worksheet (accessible from the Visual Basic toolbar's toolbox). (This is not the same as a Form button -- you can use that as well but the steps are a little different.) With the worksheet in design mode (should be already), double click the new button to reveal the empty sub: Private Sub CommandButton1_Click() Add this code: Private Sub CommandButton1_Click() If Range("Status").Value = "On" Then Range("Status").Value = "Off" ElseIf Range("Status").Value = "Off" Then Range("Status").Value = "On" End If End Sub Return to the worksheet, turn off design mode (the triangle/ruler/pencil widget) and try out your new button. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Help with toggling display
I've just moved the macro from the Personal worksheet to its own worksheet
and attached it to a button. Now it has stopped working. Weird. Any suggestion how I can get it to work again? Tom "smartin" wrote in message ... Tom wrote: Hi, I have a cell which has a defined name "status". It currently displays the word, "Off". On clicking a button I want it to toggle from "Off" to "On" and vice versa. Any help is much appreciated. TIA Tom Add a VB command button to the worksheet (accessible from the Visual Basic toolbar's toolbox). (This is not the same as a Form button -- you can use that as well but the steps are a little different.) With the worksheet in design mode (should be already), double click the new button to reveal the empty sub: Private Sub CommandButton1_Click() Add this code: Private Sub CommandButton1_Click() If Range("Status").Value = "On" Then Range("Status").Value = "Off" ElseIf Range("Status").Value = "Off" Then Range("Status").Value = "On" End If End Sub Return to the worksheet, turn off design mode (the triangle/ruler/pencil widget) and try out your new button. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
A toggling border macro | Excel Discussion (Misc queries) | |||
Toggling Visibility of items with VBA | Excel Worksheet Functions | |||
toggling | Excel Worksheet Functions | |||
Toggling autofit | Excel Discussion (Misc queries) | |||
AutoFilter toggling in VBA (How to use correctly) | Excel Discussion (Misc queries) |