C
Cynthia Gregory
I have a macro that compares two columns of data and puts either "OK" or
"Name in Col B is not in Col A" in the third column. Then it compares Col A
with Col B and does the same thing by placing the "OK" or "Name in Col A is
not in Col B" in the fourth column. Column A and Column B will have
different rows of data also. My data will be different on a daily basis so
I do not know where the last row of data will be. After the first macro has
run, I would like to place a count function on the last cell in column C and
also in column D to count the "OK"'s and also the "Names....". Can someone
please help me with this.
Here is what I have so far.
Sub compare()
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
--
Thanks,
Cynthia G.
"Information is just signs and numbers, while knowledge
involves their meaning. What we want is knowledge, but what
we get is information."
--Heinz R. Pagels
"Name in Col B is not in Col A" in the third column. Then it compares Col A
with Col B and does the same thing by placing the "OK" or "Name in Col A is
not in Col B" in the fourth column. Column A and Column B will have
different rows of data also. My data will be different on a daily basis so
I do not know where the last row of data will be. After the first macro has
run, I would like to place a count function on the last cell in column C and
also in column D to count the "OK"'s and also the "Names....". Can someone
please help me with this.
Here is what I have so far.
Sub compare()
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
--
Thanks,
Cynthia G.
"Information is just signs and numbers, while knowledge
involves their meaning. What we want is knowledge, but what
we get is information."
--Heinz R. Pagels