Good morning JohnDoe
Remember this is a togglebutton, so just changing the text on the button will do that permanently - after the first time it is clicked it will have no effect thereafter. You need to vary it based on the state of the button which will be true or false. Also, if it is a togglebutton you will need to use .ToggleButton1 and not .Command Button1.
Something like this would work :
With ToggleButton1
If .Value = True Then .Caption = "Step 1" Else .Caption = "Step 2"
End With
Incorporated into your code would look something like :
Sub ToggleProtect()
Const PW As String = "test"
With Sheets(ActiveSheet.Name)
If .ProtectContents = False Then
.Protect PW
Else
.Unprotect PW
End If
End With
With ToggleButton1
If .Value = True Then .Caption = "Step 1" Else .Caption = "Step 2"
End With
End Sub
HTH
DominicB
Bookmarks