While we can use vlookup or hlookup to return a cell value in a particular row or column. Is there a way we can lookup from both row and column to return a particular value from a cell in a grid?
Consider the case below:
(Yes, I have added more colours to the table this time š )
The construct is such that every week 5 batches ofĀ measurement is carried out. The dates are given in cells A2:A14 and batch numbers are given in cells B1:F1.
Result table forĀ measurement for specific dates and batches is given in the table below:
You could use one of the following formulas to arrive at the result:
Method1: vlookup with match
C17=VLOOKUP(A17,A2:F14,MATCH(B17,A1:F1,0),FALSE)
Of course, you could find the same result with hlookup with match. Only remember to lookup in a row instead of a column
Method2: Index with match
C18=INDEX(B2:F14,MATCH(A18,A2:A14,0),MATCH(B18,B1:F1,0))
Method3: Indirect with address and match
C19=INDIRECT(ADDRESS(MATCH(A19,A2:A14,0)+ROW(A2)-1,MATCH(B19,B1:F1,0)+COLUMN(B1)-1))
And now the bonus formula – using array
Method4: Sum as an array function
C20 {=SUM(($A$2:$A$14=A20)*($B$1:$F$1=B20)*B2:F14)}
Array formula is entered with ctrl+shift+enter
Method5: Use sumproduct as an alternate for array function
C21=SUMPRODUCT(($A$2:$A$14=A21)*($B$1:$F$1=B21)*B2:F14)
Use one of the above formulas or make one for yourself and share with others. Have fun š