Here i used this vba to unprotect sheet by inputbox
here what i want if type wrong password then a msgbox will popup and show me message (wrong password) then i click ok
the inputbox will be get popup again to enter correct password after i enter correct password then show me another msgbox (sheet unprotect successfully)
here what i want if type wrong password then a msgbox will popup and show me message (wrong password) then i click ok
the inputbox will be get popup again to enter correct password after i enter correct password then show me another msgbox (sheet unprotect successfully)
VBA Code:
Sub UnProtect()
Dim ws As Worksheet
Dim pwd As String
Dim myValue As Variant
pwd = "123" ' Put your password here
myValue = InputBox("What is the password?")
If myValue = pwd Then
For Each ws In Worksheets
ws.UnProtect Password:=pwd
Next ws
Else
MsgBox "Wrong Password"
End If
End Sub