Macro: change cell color based on value in another cell

Closed
randal.hite Posts 1 Registration date Monday December 6, 2021 Status Member Last seen December 6, 2021 - Updated on Mar 3, 2022 at 11:58 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Mar 3, 2022 at 11:27 AM
Hello,
I'm am trying to fix a spread sheet at work but what i need is a macro that i can run
to do the following

if the word Traffic appears in Column E then the cell on the same row but in Column H turns black

thanks in advance for any help with this

1 response

TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 555
Mar 3, 2022 at 11:27 AM
Hi Randal,

Here you go:
Sub RunMe()
For Each cell In Range("E2:E" & Range("E" & Rows.Count).End(xlUp).Row)
    If cell.Value = "Traffic" Then Cells(cell.Row, "H").Interior.ColorIndex = 1
Next cell
End Sub


Best regards,
Trowa
1