+ Reply to Thread
Results 1 to 11 of 11

Conditionally Locking Cells

Hybrid View

  1. #1
    Registered User
    Join Date
    08-20-2007
    Posts
    41

    Conditionally Locking Cells

    Hi, I need to lock a cell (F21) if J26 is less than 100. Can't work out how in conditional formatting. Is there a different way?

    This is what I need to do:

    F21=(IF,J26<100,Locked,Unlocked)
    Last edited by beesus311; 02-23-2008 at 08:32 AM.

  2. #2
    Forum Contributor WinteE's Avatar
    Join Date
    04-07-2007
    Location
    Netherlands
    Posts
    544
    Copy the code below to the VBA object of the worksheet these cells are in :

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("K26")) Is Nothing Then
        If Target.Value > 100 Then
            ActiveSheet.Unprotect
            Range("F21").Locked = True
            ActiveSheet.Protect
        Else
            ActiveSheet.Unprotect
            Range("F21").Locked = False
            ActiveSheet.Protect
        End If
    End If
    
    End Sub
    Erik
    Just keep it simple !


    http://www.excelguide.eu
    In English as well as in Dutch

  3. #3
    Registered User
    Join Date
    08-20-2007
    Posts
    41

    Question Not sure what that means - please explain further

    I'm not that familiar with how to do that. Could you tell me how that works? Sounds more advanced than I have so far learned.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    You could put a custom Validation on F21 of =(99<J26)
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Registered User
    Join Date
    08-20-2007
    Posts
    41
    and how would I do that? I'm not sure what you mean.

  6. #6
    Registered User
    Join Date
    08-20-2007
    Posts
    41
    I've tried that and it doesn't appear to allow me to lock and unlock cells.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    For pre-2007:

    Select Cell F21
    Go to the Data Menu and choose Validation
    Perhaps uncheck the Ignore Blanks
    On the Setting tab, choose Custom from the Allow dropdown.
    In the Formula box, type "=(99<J26)" (no quotes).
    If you want the user warned, rather than forbidden, the Error Message tab has that option.
    Click OK

    People will be unable to enter anything in F21 unless 99 < J26.

    It acts a little different than Locking a cell and Protecting a sheet, but prevents inadvertant data entry

+ 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