Lock cells
Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Lock cells

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    Nanaimo, BC
    Posts
    49
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Is there any way to lock cells so that a user cannot select or change them but let a macro change them?

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Do a search for Protect or Unprotect and you will get all of the syntax you need...

    You will obviously need to unprotect at the beginning of your macro and then Protect at the end.

  3. #3
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hi

    Yes there is! The Protect Method in VBA has an extra argument called "UserInterfaceOnly", by default this is False. If you howeve set it to True, any VBA code can change Object Properties, use Methods etc. I do however URGE you to read the help in the Excel VBE on "Protect Method" as the "UserInterfaceOnly" as it is wiped out after a save.

    On a persoanl note I have found (in Excel 97 at least) that some operations, such as FillAcrossSheets does leave the Worksheet unprotected. For this reason I have avoided this and always used the:

    Sub AnyOldCode()
    Sheet2.UnProtect Password:="Secret"
    On Error GoTo ReProtect
    'Any Code
    Reprotect:
    Sheet2.Protect Password:="Secret
    End Sub

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com