Consulting

Results 1 to 3 of 3

Thread: Protecting sheets using names from a "Defined Name"

  1. #1
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location

    Protecting sheets using names from a "Defined Name"

    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...
    Thanks in advance




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try something like this.


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

  3. #3
    Administrator
    2nd VP-Knowledge Base VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Good stuff It's working just fine.

    Thanks DRJ




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •