Morning
I have a code that highlights rows when in column B the word red is inputted, however, I need the code to work when I press enter is that possible
I have a code that highlights rows when in column B the word red is inputted, however, I need the code to work when I press enter is that possible
VBA Code:
Sub HighlightRowsWithRedInColumnB()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
' Set the active sheet
Set ws = ActiveSheet
' Find the last row with data in column B
lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
' Loop through each row
For i = 2 To lastRow ' Start from row 2 assuming headers are in row 1
If InStr(1, ws.Cells(i, "B").Value, "red", vbTextCompare) > 0 Then
' Highlight the entire row from column A to O
ws.Rows(i).Range("A1:O1").Interior.Color = RGB(255, 0, 0) ' Red color
End If
Next i
End Sub