#NAME? error on SUBSTITUTE(ADDRESS(1,a,4),"1","") function. fix and improve the formula.
Assistant
The #NAME? error you're encountering in your formula is due to the use of the CONCAT function, which may not be available in your version of Excel. The CONCAT function was introduced in Excel 2016 and later versions. To fix the error and improve your formula, you can replace the CONCAT function with the & operator, which concatenates strings in Excel and is available in all versions.
Moreover, your current formula can be simplified for better readability and efficiency by avoiding volatile functions like INDIRECT and by using more streamlined functions like INDEX, MATCH, and VLOOKUP.
Here's the corrected and improved formula:
excel
=LET(
a, MATCH(B99, 1:1, 0),
rng, OFFSET($A$1, 0, a - 1, 10000, 2),
VLOOKUP(A100, rng, 2, FALSE)
)
Explanation:
Find the Column Number (a):
excel
a, MATCH(B99, 1:1, 0)
MATCH(B99, 1:1, 0) finds the column number where the value in cell B99 appears in the first row (1:1).
Define the Lookup Range (rng):
excel
rng, OFFSET($A$1, 0, a - 1, 10000, 2)
OFFSET($A$1, 0, a - 1, 10000, 2) creates a range starting from cell $A$1, offset by a - 1 columns to the right.
The range spans 10000 rows (adjust as needed) and 2 columns (the column where B99 was found and the adjacent column to the right).
Lookup the Value (VLOOKUP):
excel
VLOOKUP(A100, rng, 2, FALSE)
VLOOKUP(A100, rng, 2, FALSE) searches for the value in A100 within the first column of rng and returns the corresponding value from the second column.
The FALSE parameter ensures an exact match.
Benefits of the Improved Formula:
Simplification: The formula is more straightforward, making it easier to understand and maintain.
Performance: By eliminating volatile functions like INDIRECT, the formula recalculates more efficiently, improving workbook performance.
Compatibility: Replacing CONCAT with the & operator ensures compatibility across different Excel versions.
Robustness: Using MATCH, OFFSET, and VLOOKUP reduces the likelihood of errors caused by text manipulation or dynamic references.
Alternative Formula Using INDEX and MATCH:
If you prefer using INDEX and MATCH functions instead of VLOOKUP, here's an alternative:
excel
=LET(
a, MATCH(B99, 1:1, 0),
col, INDEX($1:$1048576, , a),
col1, INDEX($1:$1048576, , a + 1),
c, MATCH(A100, col, 0),
INDEX(col1, c)
)
Explanation:
col retrieves the entire column where B99 is found.
col1 retrieves the adjacent column to the right.
c finds the row number where A100 matches in col.
INDEX(col1, c) fetches the corresponding value from col1.
Notes:
Adjust the range 10000 in the OFFSET function if your data spans more rows.
Ensure that B99 contains the exact header as it appears in the first row.
This formula assumes that there are no duplicate entries for A100 in the lookup column.
By adopting this simplified formula, you should resolve the #NAME? error and improve the overall efficiency and maintainability of your spreadsheet.