WobblyPenguin
New Member
- Joined
- Jan 17, 2025
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
The function is to put an 'X' on the row within that column when the keyword matches what is in column A. I have this working for column 'E' but I would like to apply it to columns F-K as well with the same function.
Any suggestions are appreciated! Thank you in advance!
Any suggestions are appreciated! Thank you in advance!
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCell As Range
Dim LookupRange As Range
Dim MatchCell As Range
' Define the key cell (E39) and the lookup range (column A)
Set KeyCell = Me.Range("E39")
Set LookupRange = Me.Range("A1:A" & Me.Cells(Me.Rows.Count, "A").End(xlUp).Row)
' Check if E39 is the changed cell
If Not Intersect(Target, KeyCell) Is Nothing Then
Application.EnableEvents = False
' Only proceed if E39 has a value
If KeyCell.Value <> "" Then
For Each MatchCell In LookupRange
If MatchCell.Value = KeyCell.Value Then
MatchCell.Offset(0, 4).Value = "X" ' Offset to column E
End If
Next MatchCell
End If
' Do nothing if E39 is cleared; keep the existing "X" values
Application.EnableEvents = True
End If
End Sub