View Full Version : Need Help testing if a cells contents match that of a cell in another column

03-26-2008, 12:36 PM

I am trying to test a column of cells to see if an individual cell's contents match the cell contents of any cell in another column.

What I have is two list of data, in alpha-numeric format. I want to see what data exist in both lists.

Thanks in advance,

03-26-2008, 01:05 PM
You may start with the following, only to get a first feel of one of several ways of checking if cells match. Suppose the columns to check are E and F.
Sub test_MatchCells()
Dim i As long, cell As Range, rng1 As Range, rng2 As Range
Set rng1 = Range(Range("E1"), Range("E" & Rows.Count).End(xlUp))
Set rng2 = Range(Range("F1"), Range("F" & Rows.Count).End(xlUp))
On Error Resume Next
For Each cell In rng1
i = WorksheetFunction.Match(cell.Value, rng2, 0)
If Err Then
MsgBox "Found " & cell.Value & " " & "Row:" & i
End If
End Sub

03-26-2008, 04:20 PM
Have you seen this excellent programme (http://members.iinet.net.au/~brettdj/)?