Can anyone help me with a simple problem.
I don't know much about VBA but can tweak code I find online to do some applications.
I want to use a toggle button to hide a range, but only do this on the worksheet that the toggle button is active on.
The code I found on-line is for all worksheets, but I don't know how to fix it.
Does anyone know how to fix this code?
I don't know much about VBA but can tweak code I find online to do some applications.
I want to use a toggle button to hide a range, but only do this on the worksheet that the toggle button is active on.
The code I found on-line is for all worksheets, but I don't know how to fix it.
Does anyone know how to fix this code?
Private Sub ToggleButton4_Change()
Application.ScreenUpdating = False
Dim ws As Worksheet
With ToggleButton4
If ToggleButton4.Value = True Then
ToggleButton4.BackColor = RGB(255, 199, 206)
ToggleButton4.ForeColor = RGB(192, 0, 0)
For Each ws In Worksheets
With ws
.Unprotect ("")
.Range(.Columns(38), .Columns(43)).Hidden = True
.Protect ("")
End With
Next ws
.Caption = "Show"
Else
ToggleButton4.BackColor = &H8000000F
ToggleButton4.ForeColor = RGB(0, 0, 0)
For Each ws In Worksheets
With ws
.Unprotect ("")
.Range(.Columns(38), .Columns(43)).Hidden = False
.Protect ("")
End With
Next ws
.Caption = "Hide"
End If
End With
Application.ScreenUpdating = True
End Sub