# Compare two sheets in excel

=IF(ISNA(VLOOKUP(A2,SHEET1!\$A\$2:\$A\$70000,1,FALSE)),"NO","YES")

Trying to compare two sheets with the values from A2 if it matches the value on the other sheet any thing in the column
LVL 2
###### Who is Participating?

x

Excel VBA DeveloperCommented:
Your formulas in the workbook are using the TRUE argument in the VLOOKUP instead of FALSE.  They're also looking for 100 columns across; should just be 1.  Your example was correct.

They should be:
[Test1] sheet, B2:  =IF(ISNA(VLOOKUP(A2,TEST2!\$A\$2:\$A\$70000,1,FALSE)),"NO","YES")
[Test2] sheet, B2:  =IF(ISNA(VLOOKUP(A2,TEST1!\$A\$2:\$A\$70000,1,FALSE)),"NO","YES")

-Glenn
0

Excel VBA DeveloperCommented:
I see no issue with your formula (tested in an example workbook).  What seems to be the problem?

-Glenn
0

Author Commented:
0

Author Commented:
in sheet test1 line 9 matches with test2 when its incorrect :(
0

Excel & VBA ExpertCommented:
You may also use the following functions to get the desired output...

On Test1,
In B2
``````=IF(ISNUMBER(MATCH(A2,TEST2!A:A,0)),"Yes","No")
``````

On Test2,
In B2
``````=IF(ISNUMBER(MATCH(A2,TEST1!A:A,0)),"Yes","No")
``````
0

Excel VBA DeveloperCommented:
^Those work.  So do these:

[Test1] sheet, B2:  =IF(COUNTIF(TEST2!\$A\$2:\$A\$70000,A2)>0,"YES","NO")
[Test2] sheet, B2:  =IF(COUNTIF(TEST1!\$A\$2:\$A\$70000,A2)>0,"YES","NO")

But it's also important for the requester to understand why the formalas didn't work.

-Glenn
0

Excel & VBA ExpertCommented:
@Glenn
The advantage of Match over Countif is, in Match you can reference the whole columns and the formula will not be evaluated for the whole columns and will stop once it finds the first occurrence of lookup value. So it will be comparatively faster than countif.
0

Commented:
If you want to see the comparison side-by-side, you could also add a column to both sheets and create a pivot table which points out the differences.  See attached,  Just a thought...
EE.xlsx
0

Excel & VBA ExpertCommented:
The chosen answers resolved the question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.