XLOOKUP Array Arguments Different Size Fix
In this article
To fix the "array arguments to XLOOKUP are of different size" error, you must ensure that the lookup_array (where you are searching) and the return_array (where the result comes from) cover the exact same number of rows or columns. If your lookup range is A2:A100 and your return range is B2:B101, the formula will fail because the arrays are mismatched in length.
What You'll Need
- A spreadsheet application that supports XLOOKUP (such as Microsoft Excel 365, Excel 2021, or Google Sheets).
- A dataset containing at least two columns or rows: one for the search criteria and one for the desired output.
- Basic familiarity with cell referencing and range selection.
Step-by-Step
- Identify the Erroring Formula: Locate the cell displaying the #VALUE! error (or the specific warning message regarding array sizes). Click on the cell and look at the formula bar to identify the current ranges being used in the XLOOKUP function.
- Analyze the Lookup Array: Look at the second argument of your formula. This is the
lookup_array. Note the starting and ending cell references. For example, if it saysA2:A500, your lookup array consists of 499 rows. - Analyze the Return Array: Look at the third argument of your formula. This is the
return_array. Check if the start and end points match the lookup array. If the return array isB2:B501, it contains 500 rows, creating a mismatch with the 499 rows in the lookup array. - Standardize the Row/Column Count: Adjust the references so they are identical in scale. If your lookup array is
A2:A500, change your return array toB2:B500. Ensure that both start at the same row number and end at the same row number. - Verify Directional Consistency: Ensure both arrays are oriented the same way. If your lookup array is a vertical column (e.g., A2:A500), your return array must also be a vertical column (e.g., B2:B500). You cannot use a vertical column for the lookup and a horizontal row for the return within a single standard XLOOKUP call.
- Apply Absolute References: To prevent the array sizes from shifting when you drag the formula down to other cells, wrap the range references in dollar signs. Change
A2:A500to$A$2:$A$500andB2:B500to$B$2:$B$500. This locks the size of the arrays. - Test the Formula: Press Enter. The error should disappear, and the formula should now return the correct value based on your lookup key.
Common Mistakes
One of the most frequent mistakes is the "Off-by-One" error. This happens when a user selects the header row for one array but not the other. For instance, selecting A1:A100 for the lookup but B2:B101 for the return. While both ranges contain 100 cells, they are shifted, which can lead to the formula returning the value from the row below the intended target, or triggering a size error if the ranges are not perfectly aligned.
Another common error is mixing whole-column references with specific range references. If you set your lookup array as A:A (the entire column) but set your return array as B2:B500, the sizes are vastly different. A whole-column reference includes over a million rows in Excel, while a specific range is limited. Both must be either whole columns (A:A and B:B) or specific ranges (A2:A500 and B2:B500).
Users also frequently mistake the lookup_value (the first argument) for part of the array. The first argument is a single value or a single cell reference. The error "different size" only refers to the relationship between the second and third arguments. If you accidentally select a range for the first argument, you may encounter a "spill" error or a different array mismatch entirely.
Tips
To avoid array size errors entirely, consider converting your data into an official Excel Table (Ctrl + T). When you use Table References (Structured References), XLOOKUP uses the column names instead of cell addresses. For example, . Because Table columns are always the same length by definition, it is mathematically impossible to have a size mismatch error when using this method.
If you are working with very large datasets, avoid using whole-column references (like A:A) if you have a lot of other complex formulas in the workbook. While XLOOKUP is optimized to only look at the used range, using specific ranges or Tables is generally a better habit for workbook performance and clarity.
When selecting ranges with the mouse, hold the Shift key and use the arrow keys to ensure you have reached the exact same bottom row for both the lookup and return selections. This precision prevents the accidental inclusion of an extra empty row at the bottom of one of the arrays.
Troubleshooting
If you have matched the row numbers (e.g., 2 to 500 for both) and you are still seeing the error, check for merged cells. Merged cells can confuse the way spreadsheet software calculates the size of a range. Unmerge any cells within your lookup and return arrays to see if the error resolves.
If the error persists, check for hidden rows or filtered data. While filters usually do not change the size of a range reference, they can make it difficult to see where a range actually ends. Clear all filters and manually inspect the last cell of each range to ensure they align.
If you are using a dynamic array or another formula to generate your lookup or return arrays, ensure that those source formulas are not returning different lengths. For example, if you use the FILTER function to create your lookup_array, but a static range for your return_array, the FILTER function might return 10 rows while your static range is 100 rows, causing the mismatch.
As a final resort, try rewriting the formula from scratch in a new cell. Sometimes, invisible characters or corrupted cell formatting can cause erratic behavior. Type the formula manually rather than copying and pasting it from another source.
Frequently Asked Questions
Can I use XLOOKUP with arrays of different sizes if I use a wildcard?
No. The match mode (wildcards) only affects how the lookup value is compared to the lookup array; it does not change the requirement that the lookup array and return array must be the same size.
Does this error happen if the arrays are in different worksheets?
Yes, it can. The arrays can be on different sheets or even in different workbooks, but the number of cells in the lookup range must still exactly match the number of cells in the return range.
Why does VLOOKUP not have this specific error?
VLOOKUP uses a single table array (a block of cells) and a column index number. Because it looks at one cohesive block, the "lookup" and "return" areas are inherently the same height. XLOOKUP separates these into two different arguments, allowing for more flexibility but introducing the possibility of size mismatches.
What happens if my return array is larger than my lookup array?
The formula will return a #VALUE! error. XLOOKUP requires a 1:1 mapping between the search range and the result range to know exactly which corresponding cell to return.
Can I use a horizontal range for one and a vertical range for the other?
No. Both arrays must share the same orientation. If the lookup array is a row, the return array must be a row of the same length. If the lookup array is a column, the return array must be a column of the same height.