Results 1 to 2 of 2

Thread: Lock Or Unlock Entire Row Depending On Value In Each Cell In A Column

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0

    Lock Or Unlock Entire Row Depending On Value In Each Cell In A Column

    i need a help
    the below vba helps to lock the corresponding row when double clicked a cell in Column "W'
    also when we unlock using unprotect sheet with password all the rows get unlocked.


    i need this to be changed as -
    lock the row only when i enter a value (say "105") in a cell (Say "BB1"),and the full row in the column A (containing value "105") should be locked. like wise there should be option in a cell (Say "BC1") to unlock a particular row too when value password given and value entered in "BC1"

    Code:
    PrivateSub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    Dim AreYouSure AsLong
    
    Set rng = Columns("W:W")
    If Intersect(Target, rng) IsNothingThenExitSub
    
    AreYouSure = MsgBox("Are you sure you want to lock this row? There's no going back from here...", _
    vbYesNoCancel + vbQuestion, "Lock this row?")
    
    If AreYouSure = 6 Then' True
    With ActiveSheet
    .Unprotect "password"
    Target.EntireRow.Locked = True
    .Protect "password"
    Last edited by Excel Fox; 12-22-2014 at 07:34 AM. Reason: Code Tags

  2. #2
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Rep Power
    0
    Last edited by DocAElstein; 03-01-2024 at 02:54 PM.

Similar Threads

  1. Replies: 1
    Last Post: 02-25-2014, 10:55 PM
  2. Replies: 1
    Last Post: 09-03-2013, 10:04 PM
  3. Delete Entire Row For All Empty Cells In Column
    By johnreid7477 in forum Excel Help
    Replies: 4
    Last Post: 06-15-2013, 05:50 AM
  4. Replies: 3
    Last Post: 12-05-2012, 09:51 PM
  5. How to Lock or Unlock row basis previous cell input?
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 2
    Last Post: 07-25-2012, 02:40 PM

Posting Permissions

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