onthegreen03
Board Regular
- Joined
- Jun 30, 2016
- Messages
- 168
- Office Version
- 365
- Platform
- Windows
Hi - I set up a toggle button (ActiveX Controls) that hides/unhides columns, code is attached below. How would I change the code if I wanted to hide/unhide the same columns but on a different sheet? I want to keep the toggle button on the active sheet (let's call that "Sheet 1") and when pressed will hide/unhide columns on "Sheet 2". Thanks for your help!
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "C:N"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
ToggleButton1.Caption = "Show Months"
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Months"
End If
End Sub
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "C:N"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
ToggleButton1.Caption = "Show Months"
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Months"
End If
End Sub