Vincent88
Active Member
- Joined
- Mar 5, 2021
- Messages
- 382
- Office Version
- 2019
- Platform
- Windows
- Mobile
Hi Guys, Need advice to modify the code to use Cell B1 as toggle button to hide and unhide the columns.
Right now, when click B1, it hides the columns but I have to move cursor to other cell & click once to open columns.
Right now, when click B1, it hides the columns but I have to move cursor to other cell & click once to open columns.
VBA Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Select Case Sh.Name
Case "Data"
Exit Sub
Case Else
End Select
If g_blnWbkShtSelChange Then Exit Sub
If Selection.Count = 1 Then
If Not Intersect(Target, Range("B1")) Is Nothing Then
g_blnWbkShtSelChange = True
Columns("C:G").EntireColumn.Hidden = True
Else
Columns("C:G").EntireColumn.Hidden = False
End If
End If
End Sub