Formula Errors

Fix an Excel Wrong Data Type Error in a Closest-Value Array Formula

Huda QurayshiHuda Qurayshi Nov 20, 2026 869 views

Question details

Find the closest value with an Excel array formula without a wrong data type error.

Fix an Excel Wrong Data Type Error in a Closest-Value Array Formula
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.
Before you start

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.

Solution 1Recommended

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.

1
Check the inputs

In the worksheet, make sure B1 and every cell in B4:B13 contain numeric values, with no text or blank cells.

2
Enter the formula

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.

3
Confirm the formula

In older Windows versions of Excel, press Ctrl+Shift+Enter instead of Enter. In Excel versions that support dynamic arrays, press Enter.

Enter the closest-value formula as an array formula
Array formula braces: In older Excel versions, Excel may display braces around a successfully entered array formula. Do not type the braces yourself.
Find the closest value in WPS

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. 1. Open the workbook: Open WPS Spreadsheets and use Open to select your workbook.
  2. 2. Check the data: Make sure B1 contains the numeric target and B4:B13 contains only numbers.
  3. 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. 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.
Find the closest numeric value above or below a targetOpen and save Microsoft Excel XLSX and XLS filesUse familiar spreadsheet functions and formulasWork in a familiar, easy-to-use interface
QA img-9

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.