+ Reply to Thread
Results 1 to 39 of 39

Conditional Unlocking

Hybrid View

  1. #1
    Registered User
    Join Date
    01-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Conditional Unlocking

    Thank you very much. To make sure I'm doing this right...the sheet is protected, and b3:h14 are locked. I right click on the sheet, and go to 'View Code'. I then go to Insert->Module and copy and paste the code in there. Is there anything else I need to do to 'run' the subroutine?

    Quote Originally Posted by jaslake View Post
    Hi hektisk

    I think this does as you requested
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Range("A4:A14")) Is Nothing Then
            If Target.Value = "New Assessment (No DC)" Then
                ActiveSheet.Unprotect
                Target.Offset(0, 1).Resize(1, 7).Locked = False
                ActiveSheet.Protect
            Else
                ActiveSheet.Unprotect
                Target.Offset(0, 1).Resize(1, 7).Locked = True
                ActiveSheet.Protect
            End If
        End If
    End Sub
    Place the code in Sheet1 Module.

    Let me know of issues.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional Unlocking

    Hi hektisk
    Almost...right click on the sheet (Sheet1) based on your sample file...copy the code into the window on the right. The code DOES NOT go in a general module...it goes in the sheet module.
    See attached.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    01-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Conditional Unlocking

    OK, prior to your post I had put the code both in the worksheet module and general module just in case, and but neither seemed to work. I opened the workbook you sent me, enabled macros, and every cell from b3:h13 are locked, no matter the data in a3:a13. I see the text you inputted in b7:b9, so I'm not sure what I'm doing wrong. Is there something else I need to do? Thank you again.

    Quote Originally Posted by jaslake View Post
    Hi hektisk
    Almost...right click on the sheet (Sheet1) based on your sample file...copy the code into the window on the right. The code DOES NOT go in a general module...it goes in the sheet module.
    See attached.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional Unlocking

    Hi hektisk
    I'd be glad to help you debug this but I'm color blind...not kidding...remove the colors from your file and repost...can't "see" what's going on.

  5. #5
    Registered User
    Join Date
    01-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Conditional Unlocking

    Quote Originally Posted by jaslake View Post
    Hi hektisk
    I'd be glad to help you debug this but I'm color blind...not kidding...remove the colors from your file and repost...can't "see" what's going on.
    Ah! Sorry. Most of the colors were unnecessary, but I did use conditional formatting to fill the cells in b:h with a very dark green when the corresponding cell in column a was blank or said 'New Assessment (No DC)' - basically my first solution, until I realized I'd be better off with locking/unlocking as appropriate.

    The colorless file is attached.
    Attached Files Attached Files
    Last edited by hektisk; 02-08-2011 at 08:50 PM.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional Unlocking

    Hi hektisk

    Ah...much better. Try the attached. I'm not certain where you're going with this. Let me know of issues.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-13-2011
    Location
    Boston, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Conditional Unlocking

    Aha! It's working great now. Thank you so much!

    One thing I'm noticing, however...since the sheet is now protected by default, new rows cannot be added to the table. It's vital that the table be expandable. I'm not sure if there's any way around this...unless if the worksheet ONLY becomes protected when one of the cells in b3:h13 (or beyond) is selected. Is this practical?

    Quote Originally Posted by jaslake View Post
    Hi hektisk

    Ah...much better. Try the attached. I'm not certain where you're going with this. Let me know of issues.

+ 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