Alfredathavan
New Member
- Joined
- Jun 19, 2021
- Messages
- 1
- Office Version
- 2016
- 2010
- Platform
- Windows
- Web
Hi I'm trying to insert a toggle button to hide/unhide columns but it has to be protected.
The code that I found protect/unprotect upon clicking the button to hide/unhide which is not what I want.
I need the toggle button to just hide/unhide in a protected sheet which cannot be unprotected by other users.
Below is the full code:
Private Sub Choose_Click()
End Sub
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "L:M"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub
Private Sub ToggleButton2_Click()
Dim xAddress As String
xAddress = "O:U"
If ToggleButton2.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub
Private Sub ToggleButton3_Click()
Dim xAddress As String
xAddress = "S"
If ToggleButton3.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub
The code that I found protect/unprotect upon clicking the button to hide/unhide which is not what I want.
I need the toggle button to just hide/unhide in a protected sheet which cannot be unprotected by other users.
Below is the full code:
Private Sub Choose_Click()
End Sub
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "L:M"
If ToggleButton1.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub
Private Sub ToggleButton2_Click()
Dim xAddress As String
xAddress = "O:U"
If ToggleButton2.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub
Private Sub ToggleButton3_Click()
Dim xAddress As String
xAddress = "S"
If ToggleButton3.Value Then
Application.ActiveSheet.Columns(xAddress).Hidden = True
Else
Application.ActiveSheet.Columns(xAddress).Hidden = False
End If
End Sub