View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Beep Beep Beep Beep is offline
external usenet poster
 
Posts: 101
Default Macro to compare names

Thanks Mike - Perfect:

Now the next step is that in the same workbook I have three columns A; B;
and C and would like to compare (highlight) numbers that are in all three
columns.

"Mike H" wrote:

Hi,

Right click you sheet tab, view code and paste this in

Sub stantial()
Dim myrange, myrange1 As Range
Lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Lastrow1 = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set myrange = Range("A1:A" & Lastrow)
Set myrange1 = Range("B1:B" & Lastrow1)
For Each c In myrange
For Each c1 In myrange1
If c.Value < "" And c.Value = c1.Value Then
c1.Interior.ColorIndex = 3
End If
Next
Next
End Sub

You question wasn't clear about wheter you wanted to simply match adjacent
rows or search all column B for any name in column A so this does the latter.

Mike

"Beep Beep" wrote:

I have two columns; A and B with names in them.
I would like to compare the names in column A with column B and
If I find a match, highlight the name in cell B.
And then go down one cell in column A and repeat
Until all names in column A are searched.