Home » excel » excel – VLOOKUP with multiple column matches

excel – VLOOKUP with multiple column matches

Posted by: admin May 14, 2020 Leave a comment

Questions:

Sheet 1

A   | B         | C
0   | 100001    | 855.71
0   | 100002    | 73.68
0   | 100003    | 704.58
0   | 100004    | 0
0   | 100005    | 0
0   | 100006    | 604.57
0   | 100007    | 15638.66
0   | 100008    | 1085.85

Sheet 2

A   | B         | C
0   | 100001    | 
0   | 100002    | 
0   | 100003    | 
0   | 100004    | 
0   | 100005    | 
0   | 100006    | 
0   | 100007    | 
0   | 100008    | 
0   | 100009    | 
0   | 100010    | 
0   | 100011    | 

This is what my 2 sheets in Excel looks like, I need to do a vlookup on the 2nd page that looks up the table in the first sheet, and prints out what is in Column C if column A and B match. So the match 0 and 100001 would display 855.71.

I’ve tried concatenating colum A and B together and matching that using this formula:

 =VLOOKUP(A3&B3,Sheet1!$A$1:$D$8,3,FALSE)

But i just get the #N/A error, any help would be great.

How to&Answers:

You’ll have to concatenate in a new 4th column on Sheet1 to use Vlookup in this manner. Instead though, you could use sumifs() since your lookup is a number and the lookup values appear to be unique:

=sumifs(Sheet1!C:C,Sheet1!A:A,A1,Sheet1!B:B,B1)

As an alternative, if the values in C are not numerical and you don’t want them summed, you could use a combination of index() and sumproduct() where sumproduct() will provide the row number on which a match is found and index() will retrieve the value from that row:

=index(Sheet1!C1:C500, sumproduct((A1=Sheet1!A1:A500)*(B1=Sheet1!B1:B500)*Row()), 1)

That’s ugly but it will get you out of having to make a superfluous column just for concatenating a key. Note that this will only work if there A and B are unique. If there are more than row where A and B are the same, then the ROW() returned will be summed and the lookup will be incorrect.