I have an issue that may be easy for an experienced VBA user. Sorry, I'm just really beginning to sense the power this useful tool has. I need to hide the UserForm once the user has clicked the "Lock" or "Unlock" buttons. I'm sensing there is an issue with the IF statement in the code but I can't seem to come to a conclusion. I've tried a lot of variations of Hide and Unload statements with no success. Hoping someone has an easy fix. Below is the code I currently have. The Lock button unlocks all the sheets in the workbook. Once this is complete, I would like the userform to be hid.
Code:
Private Sub GlobalUnlockButton_Click()
If GlobalUnlock.Value = "TEST" Then
For Each Worksheet In ActiveWorkbook.Worksheets
Worksheet.Unprotect Password:="INFO"
Next
Exit Sub
Else
MsgBox "You do not have Global Unlock permission"
End If
Exit Sub
End Sub
Private Sub GlobalLockButton_Click()
If GlobalUnlock.Value = "TEST" Then
For Each Worksheet In ActiveWorkbook.Worksheets
Worksheet.Protect Password:="INFO"
Next
Exit Sub
Else
MsgBox "You do not have Global Lock permission"
End If
Exit Sub
End Sub
Last edited: