I have a table in Excel with column headings that correspond to part of a dynamic named range elsewhere in my workbook. For example, I have these column headings: "10", "20", etc., and these dynamic named ranges: "ExampleRange10", "ExampleRange2", etc. I'd like to enter a VLookup formula that references ExampleRange10 by concatenating the string "ExampleRange" and the column heading "10". This would allow me to simply extend the formula across all columns in the table, instead of manually typing "ExampleRange10", "ExampleRange20", etc. in each column's formula.
I'm aware of the INDIRECT function, and have used it successfully in the past with named ranges, but it doesn't seem to be working with the dynamic named range in this case. I'm guessing this is a nuance that has something to do with how dynamic named ranges are defined by Excel (they don't show up in the named range dropdown to the left of the formula bar, and they have some interesting properties in VBA, for example). Is there a way I can use the INDIRECT formula in conjunction with a dynamic named range, or is there another way that I can go about solving this problem?
Edit: Here are the exact formulas used.
This is the main formula: =VLOOKUP(B2,INDIRECT("ExampleRange"&C1),2,FALSE)
where C1 contains "10" and the formula for my dynamic named range called "ExampleRange10" is: =OFFSET(Sheet1!$F$2,0,0,COUNTA(Sheet1!$F$2:$F$25),2)
. The main formula returns "#REF!", but it works correctly when I remove the dynamic named range formula and simply define "ExampleRange10" as a static range.
offset()
and column(), depending on your exact layout. – Segalman=VLOOKUP(B5,INDIRECT("range"&C1),1,0)
works fine for me in Excel 2007. Are you sure the rest of formula has no errors, e.g. 3rd parameter - column number in range to return? – Trichinopoly"ExampleRange"&C1
for further indirect is an option? – TrichinopolyINDIRECT
just doesn't work with dynamic named ranges... I'm currently looking into writing a user-defined function in VBA as a workaround. See link – Foamy