Hi
Something like:
Sub aaa()
Range("a1").Select
While Not IsEmpty(ActiveCell)
If WorksheetFunction.CountIf(Range("b:b"), ActiveCell)
0 Then
ActiveCell.Offset(0, 3) = "OK"
Else
ActiveCell.Offset(0, 3) = "Name in Col A is not in Col
B"
End If
ActiveCell.Offset(1, 0).Select
Wend
Range("b1").Select
While Not IsEmpty(ActiveCell)
If WorksheetFunction.CountIf(Range("a:a"), ActiveCell)
0 Then
ActiveCell.Offset(0, 1) = "OK"
Else
ActiveCell.Offset(0, 1) = "Name in Col B is not in Col
A"
End If
ActiveCell.Offset(1, 0).Select
Wend
End Sub
Tony
-----Original Message-----
Hello . . .
I would like to compare two columns of data, against each
other, using
visual basic for Excel.
I have four columns: A, B, C, & D.
Columns A and B have the initial data. Columns C and D
will have the
resulting data.
Columns C displays a message "OK" if the data in cell B1
is found
anywhere in column A. This is also true for cells B2, B3,
and so on . .
.
Column C displays a message "Name In Col B Is Not In Col
A" if the data
in cell B1 is not found anywhere in Column A. This is
also true for
cells B2, B3, and so on . . .
The number of rows, with respect to Columns A and B,
varies from day to
day.
Presently I am able to achieve this task using the
following formula
for Columns C:
=IF(COUNTIF(A:A,B2)<0,"OK","Name In Col B Is Not In Col
A")
and for Columns D this formula is used:
=IF(COUNTIF(B:B,A2)<0,"OK","Name In Col A Is Not In Col
B")
How can I do this same task in a VB macro with the number
of rows
varying daily?
Thank you for any help . . . . Regards,
---
Message posted from http://www.ExcelForum.com/
.