PDA

View Full Version : [SOLVED] Protecting sheets using names from a "Defined Name"



malik641
09-04-2005, 11:38 AM
On a workbook_open event, I want to protect sheets which the names are found from a Defined Name called "Employees". The range for the defined name is found in a sheet called "Employees" (oddly enough). How can I use that defined name (which holds the sheets' names that I want to protect).

Here is a workbook example to help understand what I'm talking about. Look at the defined name "employees". Those are the names I want to use as the worksheets' names to protect in VBA.

I'm having a tough time figuring out how to call the defined name...:dunno
Thanks in advance

Jacob Hilderbrand
09-04-2005, 12:40 PM
Try something like this.



Dim Cel As Range
For Each Cel in Range("Employees")
Sheets(Cel.Text).Protect Password:="MyPassword"
Next
Set Cel = Nothing

malik641
09-06-2005, 08:18 AM
Good stuff :thumb It's working just fine.

Thanks DRJ