+ Reply to Thread
Results 1 to 5 of 5

Unselect locked cells when protect/unprotect worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    03-31-2007
    Posts
    26

    Unselect locked cells when protect/unprotect worksheet

    Hi there,

    I got this worksheet which i will hide/unhide rows depending on user selection in a drop down list. However i do not want user to click on "locked cells". It work fine but whenever i save the document, the "locked cells" can be click. How do i disable the "locked cells" from being click? Any argument which i can add to unprotect/protect command?

    sht.Unprotect Password:="abc"
    
    ... hide/unhide row....
    
    sht.Protect Password:="abc"

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    For your sht.Protect line:
    sht.Protect Password:="abc", DrawingObjects:=True, _
        Contents:=True, Scenarios:=True
    sht.EnableSelection = xlUnlockedCells

  3. #3
    Registered User
    Join Date
    03-31-2007
    Posts
    26
    Quote Originally Posted by pjoaquin
    For your sht.Protect line:
    sht.Protect Password:="abc", DrawingObjects:=True, _
        Contents:=True, Scenarios:=True
    sht.EnableSelection = xlUnlockedCells
    Thank you very much. I got it solved with your code. Can i know the purpose for DrawingObjects, Contents and Scenarios? Can i be able to do it with just

    sht.EnableSelection = xlUnlockedCells

  4. #4
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    You should be able to remove those extra parts without issue (try it and find out!).

    They were just carried over from when I recorded the macro to get you the code. A lot of code (and this is for all readers, not just you) is simple enough to find if you simply record a macro to do the tasks you're trying to code. While not always the most efficient code, it will show you most of what you need to know to get the basic task done.

  5. #5
    Registered User
    Join Date
    03-31-2007
    Posts
    26
    Quote Originally Posted by pjoaquin
    You should be able to remove those extra parts without issue (try it and find out!).

    They were just carried over from when I recorded the macro to get you the code. A lot of code (and this is for all readers, not just you) is simple enough to find if you simply record a macro to do the tasks you're trying to code. While not always the most efficient code, it will show you most of what you need to know to get the basic task done.
    Oh... next time i will try to record a macro and see the code first. Thanks for the tips.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1