Forum Discussion
Andruw
Oct 25, 2019Copper Contributor
Higher-End Excel Formula Help
Hello. Working on a massive spreadsheet. Background needed to understand question: - You have (3) Columns, Column A, B and C - These (3) columns are on Sheet "1" - All three columns have the sa...
Netzukusan
Jan 22, 2024Copper Contributor
To achieve this in Excel, you can use an array formula with INDEX and MATCH. Since you have multiple instances where Columns A and B may have the same values, you need to use an array formula to handle this.
Assuming your data in Sheet "1" starts from row 2 (with headers in row 1), and your data in Sheet "2" starts from cell A2, you can use the following array formula in cell D4 of Sheet "2":
=IFERROR(INDEX('Sheet 1'!$C$2:$C$500, MATCH(1, ('Sheet 1'!$A$2:$A$500=A2)*('Sheet 1'!$B$2:$B$500=B2), 0)),"")
Here's how the formula works:
'Sheet 1'!$C$2:$C$500 is the range in Column C on Sheet "1" where the values to be returned are located.
MATCH(1, ('Sheet 1'!$A$2:$A$500=A2)*('Sheet 1'!$B$2:$B$500=B2), 0) searches for the first instance where both Column A and B match the criteria on Sheet "1". The multiplication (*) is used to create an array of 1s and 0s, where 1 indicates a match and 0 indicates no match.
INDEX is then used to return the corresponding value from Column C.
Remember to enter this formula as an array formula by pressing Ctrl+Shift+Enter instead of just Enter. If done correctly, Excel will surround the formula with curly braces {}.
Now, you can drag this formula down in column D of Sheet "2" to apply it to other rows.
Assuming your data in Sheet "1" starts from row 2 (with headers in row 1), and your data in Sheet "2" starts from cell A2, you can use the following array formula in cell D4 of Sheet "2":
=IFERROR(INDEX('Sheet 1'!$C$2:$C$500, MATCH(1, ('Sheet 1'!$A$2:$A$500=A2)*('Sheet 1'!$B$2:$B$500=B2), 0)),"")
Here's how the formula works:
'Sheet 1'!$C$2:$C$500 is the range in Column C on Sheet "1" where the values to be returned are located.
MATCH(1, ('Sheet 1'!$A$2:$A$500=A2)*('Sheet 1'!$B$2:$B$500=B2), 0) searches for the first instance where both Column A and B match the criteria on Sheet "1". The multiplication (*) is used to create an array of 1s and 0s, where 1 indicates a match and 0 indicates no match.
INDEX is then used to return the corresponding value from Column C.
Remember to enter this formula as an array formula by pressing Ctrl+Shift+Enter instead of just Enter. If done correctly, Excel will surround the formula with curly braces {}.
Now, you can drag this formula down in column D of Sheet "2" to apply it to other rows.