I have a worksheet containing a 'Toggle Button'. The toggle button is used to show and hide grouped columns and functions perfectly correctly, however, as soon as I protect the worksheet, clicking the toggle button generates a 'Run-time error '1004' - Unable to set the hidden property of the range class'.
This is the code I am using to show and hide the columns.
Private Sub ToggleButton1_Click()
If ToggleButton1 = True Then
ActiveSheet.Range("G:J").EntireColumn.Hidden = True
ActiveSheet.Range("L:P").EntireColumn.Hidden = False
ActiveSheet.Shapes("Drop Down 18").Visible = True
ToggleButton1.Caption = "Hide Graph"
Else
ActiveSheet.Range("G:J").EntireColumn.Hidden = False
ActiveSheet.Range("L:P").EntireColumn.Hidden = True
ActiveSheet.Shapes("Drop Down 18").Visible = False
ToggleButton1.Caption = "Show Graph"
End If
End Sub
What do I need to add to this code to prevent this problem from occuring, when the sheet is protected?
Many thanks
Bookmarks