Comparison Function

  • Thread starter DifficultyInExcel-ing
  • Start date
D

DifficultyInExcel-ing

I want to compare data on one sheet with data on another sheet (within the
same file) and then populate cells with data from that other sheet. For
example:

Column B (Sheet 1) has data that may have duplicate data from Column A
(Sheet 2). If so, I want to copy the data from Column B (Sheet 2) to Column
E (Sheet 1).

Can someone help me figure out which function(s) to use and how to formulate
the logical sequence?

Thanks!
 
B

bpeltzer

The basic test to pull data from one table based on a matching value earlier
in the same row is a vlookup. To produce a null result when there's no
match, you'd embed that inside an if function. And the formula will always
go in the cell where the result should appear.
So enter a formula in sheet 1, cell E2:
=if(isna(vlookup(b2,Sheet2!A:B,2,0)),"",vlookup(b2,Sheet2!A:B,2,0))
You could copy that formula down to as many rows of column E as you need.
(You might first enter just the vlookup part: =vlookup(b2,Sheet2!A:B,2,0)
then Insert > Function and see what the dialog tells you about the arguments
of the vlookup function).
 
Top