I have a protected sheet that I have a toggle button in. The toggle hides and unhides columns. The code failes and the toggle wont work if the sheet is protected. Is there a way to build the protect/unprotect within the toggle also? I've tried a few things but so far no good.
The only reason I have the sheet protected is to prevent a function from being overwritten or deleted...so if anything, I thought I can get the toggle to unprotect the sheet...do what it needs to do...and then reprotect again.
I'm using Excel 97
here is the current toggle code:
The only reason I have the sheet protected is to prevent a function from being overwritten or deleted...so if anything, I thought I can get the toggle to unprotect the sheet...do what it needs to do...and then reprotect again.
I'm using Excel 97
here is the current toggle code:
Private Sub CommandButton1_Click()
a = InputBox("Enter password:", "Security")
If a <> "password" Then
MsgBox "The password you entered is incorrect."
End
End If
With CommandButton1
If CommandButton1.Caption = "Hide Raw Data" Then
Range("C:D,F:G,I:J,M:P,R:S,U:V,X:Y,AA:AE,AG:AH").Select
Selection.EntireColumn.Hidden = True
CommandButton1.Caption = "Show Raw Data"
Else
Range("C:D,F:G,I:J,M:P,R:S,U:V,X:Y,AA:AE,AG:AH").Select
Selection.EntireColumn.Hidden = False
Range("C5").Select
CommandButton1.Caption = "Hide Raw Data"
End If
End With
End Sub