Vba protect unprotect worksheet in Excel
To do it in Excel, here is the answer:
- Option Explicit
- Sub SetPasswordForWorkSheet()
- ActiveSheet.Protect Password:="ExamplePassword"
- End Sub
Description:
a) Line 3 - hardcodes the password. One option is to get user nput for Password using InputBox
b) To unprotect WorkSheet, the command becomes, ActiveSheet.UnProtect Password:="ExamplePassword"