INDIRECT and MATCH
Assumptions:
- Each set of data (B3:E8, B10:E15, B17:E22) has the same dimensions.
- The column heading values are unique.
Goal:
Dynamically generate cell coordinates to use in the INDIRECT function to retrieve the data in that cell.
Example:
Using "value" (G3) = "H" , I want to retrieve the values from C18:C22 and display them in G4:G8.

Named Ranges:
lvl_1 B3:D3 // "A", "B", "C"
lvl_2 B10:D10 // "D", "E", "F" //
lvl_3 B17:D17 // "G", "H", "I" //
value G3 // Search Value ("H" in example)
FORMULA in each of G4:G8
=IFERROR(INDIRECT("R"&
IFERROR(ROW(lvl_1)+ROW()-ROW(value)&"C"&MATCH(value,lvl_1,0)+MIN(COLUMN(lvl_1))-1,
IFERROR(ROW(lvl_2)+ROW()-ROW(value)&"C"&MATCH(value,lvl_2,0)+MIN(COLUMN(lvl_2))-1,
(ROW(lvl_3)+ROW()-ROW(value)&"C"&MATCH(value,lvl_3,0)+MIN(COLUMN(lvl_3))-1))),
0),"-")
My INDIRECT formula Used R1C1:
FYI: My INDIRECT formula specified R1C1 notation.
This was achieved using the "FALSE" (/"0") flag. A1 is
the default notation if nothing specified.
The following are all equivalent.
=INDIRECT("R18C3",0) // R1C1
=INDIRECT("R18C3",FALSE) // R1C1
=INDIRECT("C18") // A1 (Default)
=INDIRECT("C18",1) // A1
=INDIRECT("C18",TRUE) // A1
NOTES
- Inserting additional columns in your matrix tables will not break anything.
- Adding additional rows in your data tables will also not break anything provided you do the same for all levels, whether populated with data or not.
- Formula could made smaller using helper columns/cells, and/or hardcoded values and/or leveraging tables but you know best how you'll use it.
- Follow the same format to add additional levels.
Example Solving in cell G4
To make the formula smaller and easier to follow I have pre-solved values below which I will plug into the formula.
lvl_1 = B3:D3 = {"A","B","C"}
lvl_2 = B10:D10 = {"D","E","F"}
lvl_3 = B17:D17 = {"G","H","I"}
value = G3 = "H" // Search Value
ROW() = ROW(G4) = 4
ROW(value) = ROW(G3) = 3
ROW(lvl_1) = ROW(B3:D3) = 3
ROW(lvl_2) = ROW(B10:D10) = 10
ROW(lvl_3) = ROW(B17:D17) = 17
COLUMN(lvl_1) = COLUMN(B3:D3) = {"2","3","4"}
COLUMN(lvl_2) = COLUMN(B3:D3) = {"2","3","4"}
COLUMN(lvl_3) = COLUMN(B3:D3) = {"2","3","4"}
MIN(COLUMN(lvl_1)) = MIN({"2","3","4"}) = 2
MIN(COLUMN(lvl_2)) = MIN({"2","3","4"}) = 2
MIN(COLUMN(lvl_3)) = MIN({"2","3","4"}) = 2
so
=IFERROR(INDIRECT("R"&
IFERROR(ROW(lvl_1)+ROW()-ROW(value)&"C"&MATCH(value,lvl_1,0)+MIN(COLUMN(lvl_1))-1,
IFERROR(ROW(lvl_2)+ROW()-ROW(value)&"C"&MATCH(value,lvl_2,0)+MIN(COLUMN(lvl_2))-1,
(ROW(lvl_3)+ROW()-ROW(value)&"C"&MATCH(value,lvl_3,0)+MIN(COLUMN(lvl_3))-1))),
0),"-")
becomes
=IFERROR(INDIRECT("R"&
IFERROR( 3+4-3&"C"&MATCH("H",{"A","B","C"},0)+2-1,
IFERROR(10+4-3&"C"&MATCH("H",{"D","E","F"},0)+2-1,
17+4-3&"C"&MATCH("H",{"G","H","I"},0)+2-1)),
0),"-")
then
=IFERROR(INDIRECT("R"&
IFERROR(!ERROR,
IFERROR(!ERROR,
"18C3")),
0),"-")
and
=IFERROR(INDIRECT("R18C3",0),"-")
or
=INDIRECT("R18C3",0)
finally
="1-HHH"
By extension, G4:G8 in example image above would resolve to:
F G
+---------------+----------------------+
3 | Search Value: | ="H" |
+---------------+----------------------+
4 | | =INDIRECT("R18C3",0) |
+---------------+----------------------+
5 | | =INDIRECT("R19C3",0) |
+---------------+----------------------+
6 | | =INDIRECT("R20C3",0) |
+---------------+----------------------+
7 | | =INDIRECT("R21C3",0) |
+---------------+----------------------+
8 | | =INDIRECT("R22C3",0) |
+---------------+----------------------+