Home » excel » comparison – How to compare two columns value in excel?

# comparison – How to compare two columns value in excel?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have over 100k rows of data like below:

``````ALLA,ALLA,"Company1, Inc.","Company1, Inc.",PSA,PSA,1,1,FALSE,FALSE
BCCO,BCCO,"Company2, Inc.","Company2, Inc.",PSB,PSB,1,1,FALSE,FALSE
CTTP,CTTP,"Company3, Inc.","Company3, Inc.",PSC,PSC,1,1,FALSE,FALSE
CMMZ,CMMZ,"Company4, Inc.","Company4, Inc.",PSD,PSD,1,1,FALSE,FALSE
``````

I want to know how to figure if data in column 1 is the same as column 2, column 3 as column 4 and so on. How could I do that in excel?

Following Cory’s formula, I found that I can compare whole columns using:

``````=if(A:A=B:B, "yay", "aww")
``````

Problem is I have a header in the file:

``````c - symbol, symbol, c - companyname,    companyname,    c - tradingvenue,   tradingvenue,   c - tierrank,   tierrank,   c - iscaveatemptor, iscaveatemptor
``````

Shouldn’t this cause A:A=B:B to be false?

How to&Answers:

Given this:

``````   |  A  |  B  |
---+-----+-----+
1 |  X  |  X  |
---+-----+-----+
2 |  Y  |  Y  |
---+-----+-----+
3 |  Z  |  Z  |
``````

The formula `=SUMPRODUCT(--(A1:A3=B1:B3))` will tell you how many times the `A` value matches the `B` value.

You should get `3` as a result here. If, for example, you change `B3` to `Q` then it will give you `2`.

To do this on two columns without specifying the end of the range, try:

``````=SUMPRODUCT(--(A:A=B:B),--(LEN(A:A)>0))
``````

### Answer：

I’ve been using Excel since 1991, and unless you want to write a VB macro, I think the best way is to do the simple IF statement suggested in the comments. If you need to test several columns at once, which is what your question suggests, then I’d do

``````=IF(AND(A1=B1,C1=D1,E1=F1,G1=H1),0,1)
``````

Fill that formula down the column and then you’ll be able to

1. instantly count the number of rows that don’t match
2. with a data-filter, select all the rows which have a ‘1’, so you’ll be able to examine the rows that don’t match