PDA

View Full Version : Simple Comparison



Shaolin
03-18-2008, 06:18 AM
I have a list of email addresses in column A and B. All the email addresses in column B (the shorter list) is included in column A. How can I print in column C, the email addresses included in column A and NOT in column B.

THANKS!!

Bob Phillips
03-18-2008, 06:31 AM
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

If IsError(Application.Match(.Cells(i, TEST_COLUMN).Value, .Columns(2), 0)) Then

NextRow = NextRow + 1
.Cells(i, TEST_COLUMN).Copy Worksheets("Sheet2").Cells(NextRow, "A")
End If
Next i

End With

End Sub

Shaolin
03-18-2008, 07:01 AM
Thanks, but the results are not printing on column C.

Bob Phillips
03-18-2008, 07:11 AM
Missed that bit



Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

If IsError(Application.Match(.Cells(i, TEST_COLUMN).Value, .Columns(2), 0)) Then

NextRow = NextRow + 1
.Cells(i, TEST_COLUMN).Copy .Cells(NextRow, "C")
End If
Next i

End With

End Sub

Shaolin
03-18-2008, 07:32 AM
Thanks a bunch. You are very talented