+ Reply to Thread
Results 1 to 4 of 4

Lock Cell based on Condition and Repeat till Last Row

Hybrid View

  1. #1
    Forum Contributor wamp's Avatar
    Join Date
    11-10-2008
    Location
    Norway
    MS-Off Ver
    97, 2000 & 2003 (diff. workstations)
    Posts
    184

    Re: Lock Cell based on Condition and Repeat till Last Row

    I think it would be easier to accomplish this in a worksheet-change event

    like this for example.
    Private Sub Worksheet_Change(ByVal Target As Range)
    
    If Target.Column = 5 and target.row >= 17 And Target.Value <> "YES" Then  ' Check whether the changed cell is in column E and is in row17 or below, and contains something other than "YES"
    
    ActiveSheet.Unprotect
    Target.Offset(0, 2).Clear
    Target.Offset(0, 2).Locked = True
    Target.Offset(0, 2).Value = 0
    ActiveSheet.Protect
    End If
    
    'EDIT: and maybe this code to unlock the cell?
    'If Target.Column = 5 and target.row >=17 And Target.Value = "YES" Then Target.Offset(0, 2).Locked = False
    
    End Sub
    Last edited by wamp; 05-21-2010 at 05:51 AM. Reason: added code
    _______________________________________________
    Remember:

    Read the rules!

    Use code tags! Place [CODE] before the first line of code and [/CODE] after the last line of code.

    Mark your post [SOLVED] if it has been answered satisfactorily.
    To do this, click EDIT in your original post, click GO ADVANCED and set the PREFIX. It helps everybody!

    If you are approve (or disapprove) of any members response to your problem, please click the star icon underneath their post and comment. It matters.

+ 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