Excel, if two columns match on different tabs, paste value from third column

0

I have two different tabs in excel. Tab1 has three columns (ID1, ID2, and Value). Tab2 has two columns (ID1, ID2), and I'm trying to write a function that will transfer "Value" from Tab1 into the third column of Tab2 if ID1 and ID2 match on both tabs. I've tried writing functions through VLOOKUP and INDEX (given other STACKS Overflow questions/answers), but am having a tough time figuring this one out. All advice would be appreciated!

Tab1 with columns ID1, ID2, and Value

Tab2 with columns ID1, ID2, and Value which I'm hoping to retrieve from Tab 1 if ID1 and ID2 match

Stephanie Galla

Posted 2018-02-01T23:01:42.327

Reputation: 1

Answers

0

Use SUMIFS()

=SUMIFS(Tab1!C:C,Tab1!A:A,A2,Tab1!B:B,B2)

See this StackOverflow Answer:

https://stackoverflow.com/questions/42492758/vlookup-using-2-columns-to-reference-another

Scott Craner

Posted 2018-02-01T23:01:42.327

Reputation: 16 128

Thank you Scott Craner. This worked beautifully with my dataset! Thank you for the link to the other StackOverflow Answer as well. – Stephanie Galla – 2018-02-19T02:21:13.107

0

In the second tab, use MATCH to look up row matching ID1 and ID2 in TAB1. If the row is the same, then use INDEX to pull value. I've done this all in one formula below, but if you are new to MATCH and INDEX, you might put pieces of formula in different columns to make sure you understand.

You don't say what you want Value to be in Tab 2 if ID1 and ID2 don't match, so I've made it "no match". (You could, instead use a blank, or zero.)

Here's the formula for the column in Tab 2 where you want the Value. I've assumed ID1 is in column A and ID2 is in Column B in both tabs.

In Row 2 of Tab2 you can use the following formulas:

Column C: Match($A2,'Tab1'!$A:$A,0)
Column D: Match($b2,'Tab1'!$B:$B,0)
Column E: IF($C2=$D2,INDEX('Tab1'!$C:$C,$C2),"no match")

Obviously, this could be combined in a single if statement if you so desire. If there is no match for either of the IDs, you'll get an #N/A error. You can avoid this by using ISNA around the returned value in Column E.

Jonathan

Posted 2018-02-01T23:01:42.327

Reputation: 208