I am trying to use INDIRECT() to set a range for a VLOOKUP() function based on a defined numeric value. When stepping through the VLOOKUP() formula, the INDIRECT() function returns what appears to be an acceptable range for my purposes. However, when running the formula, a "#N/A" error is returned and I'm not sure why.
To give a little more flavor, I'm using LEFT() and ADDRESS() to determine the column heading letter based on a MATCH() of a separate value across the top row. Using a fixed offset, the MATCH() functions return the correct column headers and I supply the constants for the range size. Below is my formula:
=VLOOKUP(J2,INDIRECT("$"&LEFT(ADDRESS(1,MATCH($H2,ZAS_Lookup,0)+8,4),1+(MATCH($H2,ZAS_Lookup,0)+8>26))&"$1:$"&LEFT(ADDRESS(1,MATCH($H2,ZAS_Lookup,0)+9,4),1+(MATCH($H2,ZAS_Lookup,0)+9>26))&"$29"),2,TRUE)
As I mentioned, when stepping through to the last step before final calculation, the formula appears as if it will condense down to the following:
=VLOOKUP(5,$DW$1:$DX$29,2,TRUE)
This is not the case, however, since it returns a #N/A. Any idea why? Do I need to use a different function to set the range dynamically?
=VLOOKUP(5,$DW$1:$DX$29,2,TRUE)
? – Dmitry PavlivVLOOKUP
returns the#N/A
error value" - from MS documentation. Is it true for you? office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx – Dmitry PavlivVlookup
, it's no need to use sheet name inINDIRECT
function – Dmitry Pavliv