Rhonda Epps
New Member
I'm setting up a spreadsheet with several rows of data (individual records). I'm trying to lock and turn black columns F, G, and H if the response in column E = "N". I also want to do the same thing to columns J, K, L and M if the response in column I = "N". I need this to happen in EVERY ROW and be set up so that if someone types in one of the cells that should be locked prior to answering the trigger questions in columns E or I, the content of the cells should be deleted.
I hope Im not asking for too much!!! I found a found a thread started by ultros1234 on June 14, 2013 that similar to my issue. that thread include the following code, but since I am an excel idiot I have no idea how to adjust it to accomplish my mission.
Option Explicit
I hope Im not asking for too much!!! I found a found a thread started by ultros1234 on June 14, 2013 that similar to my issue. that thread include the following code, but since I am an excel idiot I have no idea how to adjust it to accomplish my mission.
Option Explicit
Code:
Sub UnProtectMySheetFirst()
Me.Unprotect Password:="" 'Just in case protection already applied
End Sub
Sub ProtectMySheetLast()
Me.Protect UserInterfaceOnly:=True, Password:=""
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRow As Long
UnProtectMySheetFirst
xRow = Target.Row
If Not (Intersect(Target, Range("H3:H1000")) Is Nothing) Then
& #39;changed something in col H
Range(Cells(xRow, "J"), Cells(xRow, "M")).Locked = (UCase(Trim(Cells(xRow, "H").Value)) <> "YES")
End If
& #39;Since it's possible to change both col h and col I, we'll use separate If statements
& #39;rather than an If...else statement
If Not (Intersect(Target, Range("I3:I1000")) Is Nothing) Then
& #39;changed something in col I
Range(Cells(xRow, "N"), Cells(xRow, "P")).Locked = (UCase(Trim(Cells(xRow, "I").Value)) <> "YES")
End If
ProtectMySheetLast
End Sub
Last edited by a moderator: