I am trying to see in a dynamic range ( in a column), if the cell value is equal to 0. If yes, then display a pop up message and change the color of column A, B and C (same row number) to RED.
Any help is greatly appreciated.!! Thank you.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range(Cells(9, "AD"), _
Cells(Rows.Count, "AD").End(xlUp).Resize(, 1))
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Application.Intersect(KeyCells, Range(Target.Address)) = 0 Then
MsgBox "Row " & Target.Address & " will not be considered."
End If
~~ I tried using below code in above IF
block, but get the same result of all the rows (till current count) getting a change in background color. I intend to limit color change to just that row and column A, B , C
(cells).
~~ Now, here I want to see, if the cell value is equal to '0' then the first 3 column cells (column A, B, C
of same row number should be updated with a different background color).
~~ I tried changing the complete row color to RED, but while doing so, all the rows till current row will get a color change. This is not intended. Is this happening because the range is dynamic?
For Each Cell In KeyCells
Select Case Cell.Value
Case Is = 0
Cell.EntireRow.Interior.ColorIndex = 3
Case Else
Cell.EntireRow.Interior.ColorIndes = xlNone
End Select
Next
End If
End Sub