Hi,
I need a VBA to allow me to use a toggle button to hide/unhide multiple non-adjacent columns. I have spend the last 2 hours searching this and other sources and trying many macros but none so far have worked (most I have tried don't work at all). However, I have found one that works very well with hiding/unhiding contiguous columns but I have not been able to find the correct syntax to expand this to cover others. For example, this macro clearly hides Cols F and G. In addition to F and G, in my spreadsheet, I want to hide Cols M through P, Col X, and Cols AA through AC.
Appreciate any help. Thanks in advance.
VBA code: button to show hide columns
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "F:G"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub
Bookmarks