Re: $$Excel-Macros$$ UnProtect Code Not working

2011-10-28 Thread Sam Mathai Chacko
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

Re: $$Excel-Macros$$ UnProtect Code Not working

2011-10-28 Thread Anish Shrivastava
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 =

Re: $$Excel-Macros$$ UnProtect Code Not working

2011-10-28 Thread Sam Mathai Chacko
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

$$Excel-Macros$$ UnProtect Code Not working

2011-10-28 Thread Anish Shrivastava
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