0
votes

I am having an issue. Whenever I protect a sheet using a VBA Code as followed:

Sheets("SheetName").Protect Password:= pwd

The sheet does become protected, HOWEVER, the sheet can manually be unprotected by the users when they go under the 'Review' Tab and click 'UnProtect'. No password is required even though there is one there. Please help!

1
Where is pwd assigned a value?Rory
It isn't, it's not in quotes. "pwd"mooseman

1 Answers

1
votes

I think your syntax is incorrect.

If pwd is the value of your password then you have to put it between " like this:

Sheets("SheetName").Protect Password:="pwd"

If pwd is the name of your variable that contains the password please make sure it's not empty and that you do not have a blank character after the Password:=.

It should look like this:

Dim pwd As String
pwd = "pass"

Sheets("SheetName").Protect Password:=pwd