How to compare one column to another?

J

Jim Bancroft

Hi everyone,

I have two columns of strings, both in ascending order. Similar lists but
not identical. Are there macros or other steps I can take to compare column
A with column B, so that all entries in A that aren't in B wind up in column
C? Thanks!
 
G

Guest

Hello

If your list in column A is from A1 to say A6 and list in B is from B1:B6
then enter the following in C1 and copy it down to C6

=IF(COUNTIF($B$1:$B$6,A1)>0,"",A1)

Alok
 
J

Jim Bancroft

Hi,

Unfortunately the columns don't have the same number of rows. What's more,
some entries in column A aren't in column B, and vice versa.
 
G

Guest

Hi Jim,

The formula does not require the same number of rows in columns A and B.
For instance your column A could be A1:A1000 and entries in B from B1:B500.
Then the formula in C1 will become

=IF(COUNTIF($B$1:$B$500,A1)>0,"",A1)

but it will still need to be copied down till C1000.

Hence the column C must (in my solution) have the same number of rows as in
column A - though I have seen in this newsgroup solutions that ensure that
column C does not have blanks as in my solution but has only the missing
entries right at the top of the column.

Alok
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Comparing numbers 1
VBA- Excel Programming:- 0
Comparing two columns 7
Compare two Sheets 1
String Comparison 5
Compare Two Columns 3
Compare columns for dupes 3
Macro to compare names 8

Top