Google-sheets – Update the reference in Indirect() when new columns are added

google sheets

I have a a very large spreadsheet that pulls data from another logsheet through an Indirect depending on user input on cell A1.

=INDIRECT($A$1&" Data!$AG$3")

I'm trying to add some new columns now to the logsheets, when I manually type in the sheet names

='June Data'!$AG$3

It automatically updates the $AG$3 part when I add new columns, but with indirect() it does not. Is there any way using indirect, or some other formula, where I can get Google Sheets to automatically update my referenced cells?

Best Answer

You should mark column AG in some way so it can be identified as the column that indirect needs. For example, by placing "Data" in the first row of that column.

Then you can use match to find the number of that column, which becomes a part of cell reference in R1C1 notation.

=indirect($A$1 & " Data!R3C" & match("Data", 1:1, 0), false)

This formula refers the cell in 3rd row of the column with header "Data", on the sheet specified in cell A1.