Matching cells by content then cell fill with color

C

click4mrh

Thanks to JEM, I am using this routine to color three consecutive cell
a specific color, in this case red:

Public Sub ThreeCellsRed()
ActiveCell.Resize(1,3).Interior.ColorIndex = 3
End Sub

What I need now is a way for the routine to continue to find all th
similar cells, let's say for sake of disc they are people's names, s
when I execute the above on my name, mrh, I want it to continue in th
worksheet and find all exact matches and color those same cells red.

Another thought, say my name (MRH) is in "A1" and it is also in "D1".
But in "D1" I use "=A1". Can I script a formula around "=A1" tha
would automatically fill the cell red when the above routine i
executed?

Ideas? Thx in advance, MR
 
I

icestationzbra

this code will work for a selected area. for example, select the regio
between A1 to D4 and run this code. it will colour all the cell wit
the string "mrh".

Option Explicit

Sub ColourCellsRed()

Dim rngCell As Range
Dim rngAll As Range

Set rngAll = Selection

For Each rngCell In rngAll

If rngCell.Value = "mrh" Then rngCell.Interior.ColorIndex = 3

Next rngCell

End Su
 
Top