A
amit.vasu
Hi
I was doing some VBA programming in Excel. I wanted to protect the
worksheet and in order to do so I write the code below.
*****************
For Each w In ActiveWorkbook.Worksheets
AllowSorting:=True, AllowFiltering:=True
w.Protect Password = "password"
Next
******************************************
In my workbook, I had 4 worksheet. The code above worked well for three
worksheet except the worksheet 2. It was unprotected even after
running the code above.
So I write down the following code right after the above loop.
*****************************************************
Worksheets(2).Activate
Worksheets(2).Protect Password = "password"
***************************************************************************
and again at the end I wrote the following code.
******************************************************
ActiveWorkbook.Worksheets(2).Protect Password = "password"
******************************************************
Now my problem is I can not unprotect that worksheet. When I go to
tools --> Protection --> unprotect worksheet and enter the above
password ("password") it does not work.
It give me the dialogue box saying
"The password you supplied is not correct. Verify that the caps lock
key is not......"
I would highly appreciate if someone could tell me what is wrong in
above code and what password will work to unlock the worksheet.
I can not use the free tool as client is not ready to use any other
tool. They just want the solution to unlock the worksheet by themself
without using any other tool.
Please help.
I was doing some VBA programming in Excel. I wanted to protect the
worksheet and in order to do so I write the code below.
*****************
For Each w In ActiveWorkbook.Worksheets
AllowSorting:=True, AllowFiltering:=True
w.Protect Password = "password"
Next
******************************************
In my workbook, I had 4 worksheet. The code above worked well for three
worksheet except the worksheet 2. It was unprotected even after
running the code above.
So I write down the following code right after the above loop.
*****************************************************
Worksheets(2).Activate
Worksheets(2).Protect Password = "password"
***************************************************************************
and again at the end I wrote the following code.
******************************************************
ActiveWorkbook.Worksheets(2).Protect Password = "password"
******************************************************
Now my problem is I can not unprotect that worksheet. When I go to
tools --> Protection --> unprotect worksheet and enter the above
password ("password") it does not work.
It give me the dialogue box saying
"The password you supplied is not correct. Verify that the caps lock
key is not......"
I would highly appreciate if someone could tell me what is wrong in
above code and what password will work to unlock the worksheet.
I can not use the free tool as client is not ready to use any other
tool. They just want the solution to unlock the worksheet by themself
without using any other tool.
Please help.