Hi,
I have a sheet with columns A-AZ with each column being specific to information being inputted about different businesses in rows 2-75.
For ease of matching column Z (for example) with the respective row number in view, I want to be able to have multiple toggle buttons that can hide/unhide specific columns. Currently I have one toggle button that hides Columns L:S and also unhides it. It works great. My issue comes when I try to add in a second or third toggle button. I'd like the second toggle button to hide and unhide columns D:F. Below is the code I used for the first toggle button. I simply copied the code and used it for the second button. However, when doing so, the second toggle button only HIDES and does not UNHIDE columns D:F. Can anyone help with this please?
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "L:S"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
ToggleButton1.Caption = "Show Addt'l BSV"
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Addt'l BSV"
End If
End Sub
Private Sub ToggleButton2_Click()
Dim xAddress As String
xAddress = "D:F"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
ToggleButton2.Caption = "Show Rest. Characteristics"
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
ToggleButton2.Caption = "Hide Rest. Characteristics"
End If
End Sub
I have a sheet with columns A-AZ with each column being specific to information being inputted about different businesses in rows 2-75.
For ease of matching column Z (for example) with the respective row number in view, I want to be able to have multiple toggle buttons that can hide/unhide specific columns. Currently I have one toggle button that hides Columns L:S and also unhides it. It works great. My issue comes when I try to add in a second or third toggle button. I'd like the second toggle button to hide and unhide columns D:F. Below is the code I used for the first toggle button. I simply copied the code and used it for the second button. However, when doing so, the second toggle button only HIDES and does not UNHIDE columns D:F. Can anyone help with this please?
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "L:S"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
ToggleButton1.Caption = "Show Addt'l BSV"
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
ToggleButton1.Caption = "Hide Addt'l BSV"
End If
End Sub
Private Sub ToggleButton2_Click()
Dim xAddress As String
xAddress = "D:F"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
ToggleButton2.Caption = "Show Rest. Characteristics"
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
ToggleButton2.Caption = "Hide Rest. Characteristics"
End If
End Sub