In your code above, you use another user name to unprotect it. And here you
protect it after checking for another user name. Please standardize and then
recheck. On top of that, you are counting for the number of Worksheets, and
applying protection on Sheets. Please understand Sheets and Worksheets
thanks for your reply Sam but your conclusion is not right.. below is the
code which I am using to protect the sheets and as you can see the password
is same. "Sample".
Please advice.
==
Sub prot()
Dim sht As Integer
Dim uname As String
uname =
It means the sheet is protected with another password, and that you cannot
unprotect the sheet using a password that does not match.
Sam
On Fri, Oct 28, 2011 at 9:16 PM, Anish Shrivastava wrote:
> Hi,
>
> Please see the code below, when I run the code it says "password you
> supplied is not vali
Hi,
Please see the code below, when I run the code it says "password you
supplied is not valid".
===
Sub unpro()
Dim sht As Worksheet
Dim uname As String
Dim pwd As String
uname = Environ("Username")
pwd = "Sample"
For Each sht In Worksheets
If uname = "anisku