google-sheetsgoogle-sheets-formula

Index Function - Use One Formula to Generate the Result List with Two Variables


I will use index to locate specific value in the range.

The Range

Col1 Col2 Col3 Col4
Tom Apple Orange Banana
John Earl Camomile Sri Lanka
Peter Van Bus Tram
Patrick A4 A3 A5

The row number and column number is kept in this table. These numbers are subject to changes.

Index Function Parameter

Row Column
2 3
3 2
4 4
2 2
4 3
3 1

Anticipated Result

Anticipated Result
Orange
Earl
Tram
Apple
Bus
John

Please see my shared spreadsheet: https://docs.google.com/spreadsheets/d/12JDr0J3Sbu-ZUpWveMswnPXOtP4EcA-eZzxFsV2ALlE/edit?usp=sharing

It is straightforward to use formula by inputting formulas alongside each pair of parameter. However, I want to make it simple. Can I input one formula in cell D11 to achieve the same result?


Solution

  • Using BYROW:

    You can also use BYROW as an alternative solution.

    =BYROW(A11:B16,LAMBDA(x,INDEX(A2:D5, INDEX(x,,1),INDEX(x,,2))))
    

    Sample Output:

    Output

    Reference/s:

    BYROW function

    INDEX