Sorry my fault for not reading the question properly. Replace all the code with...
In the CommandButton code
Private Sub CommandButton2_Click()
UNsht
End Sub
In a standard module
Sub UNsht()
Dim pw As String, sht As Worksheet
pw = InputBox("Enter password", "Unprotect sheets")
On Error GoTo pwerr
For Each sht In ActiveWorkbook.Worksheets
sht.Unprotect Password:=pw
Next
Exit Sub
pwerr:
If MsgBox("Incorrect password", vbRetryCancel, "Error") = vbRetry Then
UNsht
End If
End Sub
EDIT: or actually you can just put it all in the command button code
Private Sub CommandButton2_Click()
Dim pw As String, sht As Worksheet
pw = InputBox("Enter password", "Unprotect sheets")
On Error GoTo pwerr
For Each sht In ActiveWorkbook.Worksheets
sht.Unprotect Password:=pw
Next
Exit Sub
pwerr:
If MsgBox("Incorrect password", vbRetryCancel, "Error") = vbRetry Then
UNsht
End If
End Sub
Bookmarks