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.
I know this is a really old thread, but I had the same issue, so perhaps my solution can help people in the future.
Basically, I created a Macro that would delete and re-define the range upon save, and give it a name. Therefore, the INDIRECT function would work as the range was not dynamic. All you need to do is save the workbook after adding any values to the named ranges
Adding a new twist, it is possible to use a named range with the Address and Indirect functions. I have a case where I am setting named ranges for a series of tables and am using the following:
to get the address: $T$56: =ADDRESS(MATCH(S56,Linear!A:A,0),1,1,1,"Linear")
Then using the offset function copied multiple times to create a pivot table:
So, the Address function can be embedded (or wrapped) into the Indirect function to create a dynamic cell address.