sql - How to inner-join in Excel (eg. using VLOOKUP) -
is there way inner join 2 different excel spreadsheets using vlookup?
in sql, way:
select id, name sheet1 inner join sheet2 on sheet1.id = sheet2.id;
sheet1:
+----+------+ | id | name | +----+------+ | 1 | | | 2 | b | | 3 | c | | 4 | d | +----+------+
sheet2:
+----+-----+ | id | age | +----+-----+ | 1 | 20 | | 2 | 21 | | 4 | 22 | +----+-----+
and result be:
+----+------+ | id | name | +----+------+ | 1 | | | 2 | b | | 4 | d | +----+------+
how can in vlookup? or there better way besides vlookup?
thanks.
first lets list of values exist in both tables. if using excel 2010 or later in sheet 3 a2 put following formula:
=iferror(aggregate(15,6,sheet2!$a$1:$a$5000/(countif(sheet1!$a$1:$a$5000,sheet2!$a$1:$a$5000)>0),row(1:1)),"")
if using 2007 or earlier use array formula:
=iferror(small(if(countif(sheet1!$a$1:$a$5000,sheet2!$a$1:$a$5000),sheet2!$a$1:$a$5000),row(1:1)),"")
being array formula, copy , paste formula bar hit ctrl-shift-enter instead of enter or tab leave edit mode.
then copy down many rows desired. create list of id'd in both lists. assume id number , not text.
then list use vlookup:
=if(a2<>"",vlookup(a2,sheet1!a:b,2,false),"")
this return value sheet 1 matches.
Comments
Post a Comment