Consulting

Results 1 to 7 of 7

Thread: Protected Cells

  1. #1
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Porto, Portugal
    Posts
    180
    Location

    Protected Cells

    Hi All

    I have this workbook with some sheets. Each sheet has macros to run.

    Because there are 5 users (at least) with acess to the workbook, some cells must be locked, for they cannot change the structure of sheets, by erasing formulas or insert/delete rows, etc. What I want is to offer them a restricted acess only to some unprotected cells.

    But if I protect other cells by tools menu, macros dont run.

    How do I skip that?

    Thank you

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You lock some cells (Format>Cells>Protection), unlock others, and set protection (Tools>Protect).
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Porto, Portugal
    Posts
    180
    Location

    Protected Cells

    Quote Originally Posted by xld
    You lock some cells (Format>Cells>Protection), unlock others, and set protection (Tools>Protect).
    I did that, but macros contain code lines to "clear.contents" and when I execute with protection activated, they return error to those lines

  4. #4
    VBAX Regular
    Joined
    Mar 2005
    Location
    Helena, MT
    Posts
    90
    Location
    In the This WorkBook Module
    Private Sub WorkBook_Open()
    For Each ws in WorkSheets
    ws.protect "password" UserInterFaceOnly:=True
    Next ws
    End Sub
    This will protect the sheets, but allow changes via VBA

    lenze

  5. #5
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Porto, Portugal
    Posts
    180
    Location

    Protected Cells

    Quote Originally Posted by lenze
    In the This WorkBook Module
    Private Sub WorkBook_Open()
    For Each ws in WorkSheets
    ws.protect "password" UserInterFaceOnly:=True
    Next ws
    End Sub
    This will protect the sheets, but allow changes via VBA

    lenze
    Still not working

    [VBA]Private Sub WorkBook_Open()
    For Each ws In Worksheets
    ws.Protect "password", UserInterFaceOnly:=True
    Next ws
    End Sub[/VBA]

    What is missing?

  6. #6
    VBAX Regular
    Joined
    Mar 2005
    Location
    Helena, MT
    Posts
    90
    Location
    What exactly is happening? Where did you place the code? Did you save and reopen the WorkBook?

    lenze

  7. #7
    VBAX Contributor
    Joined
    Mar 2009
    Location
    Porto, Portugal
    Posts
    180
    Location
    Quote Originally Posted by lenze
    What exactly is happening? Where did you place the code? Did you save and reopen the WorkBook?

    lenze
    Sorry for last reply. I did exactly what you told me to do, except save and reopen.

    It works just fine, as I expected so.

    Thank you very much for your help and time.

    You all do a great job

    ioncila

Posting Permissions

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