Hello,
I would like to set the sheet unprotect VBA formula to use a cell value as the password to unprotect...purpose of this is I want to be able to edit that cell at anytime to update all instances of the "unprotect" password that are used over dozens of macros....
I was trying,
----------
--------Code:Sub click() Dim SH As Worksheet Const PWORD As String = ("Sheet1!b1") Worksheets("Sheet1").Protect Password = PWORD End Sub
But when it locks, I can not unlock it using the value in B1....
Any ideas?
Last edited by Chaylon; 03-13-2010 at 10:33 AM.
Hi Chaylon... Welcome to the forum. Be sure to read through the Forum Rules so you can use and follow them effectively. For instance, you'll need to EDIT that post above and put code tags around that code you used. (Like shown in my signature)
=========
Perhaps simpler would be to select the cell B1 in sheet1 and give it a NAME of PWord in the Name box. This "helps" disguise it's location, too.
Then in your macro, simply refer to the named range:
Code:Worksheets("Sheet3").Protect Range("PWord")
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thanks a LOT! now I just have to go through all 80 some macros and update the VBA, lol
Um, 80 macros?
You should consider putting the variable into a Constant or a Global variable. Then update the macros to utilize the ONE variable you've declared for that purpose. Hopefully that results in less work to maintain the macros...
Or perhaps you can use the CTRL-H (Replace) function to update all the macros at once...maybe.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Any way to fix this so that someone can't just type =pWord into any cell and it comes up with the password?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks