Fix an Excel Wrong Data Type Error in a Closest-Value Array Formula
Question details
Find the closest value with an Excel array formula without a wrong data type error.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user combines INDEX, MATCH, MIN, and ABS to find the value closest to a target.
- Observed behavior
- The array formula returns an error indicating that a value has the wrong data type.
Identify the target cell and the range to search; the examples below use B1 and B4:B13. Check whether your Excel version supports dynamic arrays and whether your formulas use commas or semicolons as argument separators.
Enter the closest-value formula as an array formula
Use this approach to find the value closest to the target, whether it is higher or lower.
The formula compares the absolute difference between each value in B4:B13 and the target in B1. If two values are equally close, it returns the first one in the range.
The original example filters for values at or above the target rather than finding the closest value on either side. Its two IF conditions also use different comparisons, which can cause inconsistent results.
In the worksheet, make sure B1 and every cell in B4:B13 contain numeric values, with no text or blank cells.
Select an empty result cell and type =INDEX(B4:B13,MATCH(MIN(ABS(B4:B13-B1)),ABS(B4:B13-B1),0)). If your Excel uses semicolons, replace the commas with semicolons.
In older Windows versions of Excel, press Ctrl+Shift+Enter instead of Enter. In Excel versions that support dynamic arrays, press Enter.

Convert numbers stored as text
Use this check if the formula still returns an error after it is entered correctly.
Calculate the closest value with WPS Spreadsheets
Use an INDEX, MATCH, MIN, and ABS array formula in WPS Spreadsheets to find the value closest to a target.
- 1. Open the workbook: Open WPS Spreadsheets and use Open to select your workbook.
- 2. Check the data: Make sure B1 contains the numeric target and B4:B13 contains only numbers.
- 3. Enter the formula: Select an empty cell and enter =INDEX(B4:B13,MATCH(MIN(ABS(B4:B13-B1)),ABS(B4:B13-B1),0)). Use semicolons instead of commas if required by your settings.
- 4. Confirm and check: Confirm the formula with Ctrl+Shift+Enter if your WPS version requires array entry; otherwise, press Enter. Check that the result is the closest value to B1.

Frequently Asked Questions
Why does my array formula return an error in older Excel versions?
Some older Excel versions require Ctrl+Shift+Enter to evaluate calculations over a range as an array. Select the formula cell, press F2, and then press Ctrl+Shift+Enter on Windows.
Does the formula return a value above or below the target?
The ABS formula compares differences on both sides of the target and returns the closest value. If two values are equally close, MATCH returns the first one in the range.
How can I tell whether a number is stored as text?
Enter =ISNUMBER(B1) in an empty cell, changing B1 to the cell you want to test. FALSE means the cell is not stored as a number.
Why does Excel reject the commas in my formula?
Excel uses the list separator from your regional settings. If your formulas require semicolons, replace each argument-separating comma with a semicolon.




