jimmytiler
New Member
- Joined
- Aug 16, 2020
- Messages
- 5
- Office Version
- 365
- 2019
- Platform
- Windows
- MacOS
I have used vba code to lock the sheet, however, when I use the 'Unlock' code it seems to unlock the sheet regardless of the password being correct??
Code:
Sub LockSheet()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
WS.Protect Password:="123456"
MsgBox "Data is locked"
End Sub
Sub UnlockSheet()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
Ws.Unprotect Password:=InputBox("Enter password")
MsgBox "Data is unlocked"
End Sub