+ Reply to Thread
Results 1 to 5 of 5

Protection properties

  1. #1
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264

    Protection properties

    I a using a macro to hide and unhide rows.

    The sheet is protected and cells are locked except for the ones that data entry is to made into. This makes it easier of users to tab through the data entry - so the code has to unprotect the sheet, unhide the rows and then protect the sheet again.

    This it does, but the protection properties change and the user can then select locked cells.

    Is there a way to maintain the protection properties?
    Code being used is as below

    ActiveSheet.Unprotect Password:="myPW"
    Select Case LCase(Rng)
    Case "yes", "Select...."
    Rows("41:65").EntireRow.Hidden = True
    Case "no"
    Rows("41:65").EntireRow.Hidden = False

    End Select
    ActiveSheet.Protect Password:="myPW"

    Regards

    Ed

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,523

    Lock and unlock cells VBA

    Hi,
    You could use VBA to unlock and lock the cells, something like this could be added to your existing code:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Thanks for that, Dave.

    The problem is that that 90% of the cells need to be locked.

    I suppose I could make them all locked and then unlock those that need to be unlocked but that would still be approx 300.....not practicable really.

    What I was really after was a way to preserve the protection properties set initially.

    Any ideas?

    Ed

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi, Ed.

    Not sure why the cells are becoming unlocked, but using the suggestion above, you could select all cells that are unprotected in the sheet (using the SHIFT and/or CTRL keys while clicking if you didn't know), then enter a name for this range (e.g. Unlocked_Cells).

    Then in the code, you could do something like:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Hi Jason,

    The changing of the protection properties seems a bit random - sometimes it happens on reopening the workbook and sometimes it just seems to have happened and I can't pin down a patten to it.

    It may be something that I have to learn to live with, but thanks for the suggestion.

    Ed

+ 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