Search code examples
xlsxxls

Can I use a content in a cell to store extract the tab name of an xls formula?


I have an xls formula as below

=IFERROR(VLOOKUP($A2, '2018-01.csv'!$A:$B, 2, FALSE), 0)

where by 2018-01.csv it the tab name.

Can I replace this tab name and defined in a cell? e.g.

=IFERROR(VLOOKUP($A2, '${J1}.csv'!$A:$B, 2, FALSE), 0)

Whereby ${J1} will take the value from cell J1 which containt 2018-01?

Note ${j1} is a wrong syntax in xls in that formula. Looking if there's one way to do that.


Solution

  • Found the answer. It's by using INDIRECT.

    =IFERROR(VLOOKUP($A2,INDIRECT("'"&J$1&".csv'!"&"$A:$B"), 2, FALSE), 0)
    

    Where cell J$1 is where it content 2018-01

    Thanks to sharing in http://spreadsheetpro.net/how-to-make-a-dynamic-reference-to-a-worksheet-in-excel-and-google-spreadsheets/