How to Linear Interpolate in Excel: Step-by-Step Guide
In this article
To linear interpolate in Excel, you don't need a built-in function—you can use the FORECAST.LINEAR function (or the older FORECAST), or write a simple formula using INDEX and MATCH to find the two surrounding points and calculate the intermediate value. The most straightforward method for a single interpolation is: =FORECAST.LINEAR(target_x, known_y_range, known_x_range), but that only works when your data is linear overall. For piecewise linear interpolation between two known points, use: =y1 + (target_x - x1) * (y2 - y1) / (x2 - x1) after locating x1, y1, x2, y2 with INDEX/MATCH. This guide walks you through both approaches, plus common pitfalls and fixes.
What You'll Need
- Microsoft Excel (any recent version; the steps work in Excel 2016 and later, including Microsoft 365). Menu labels may differ slightly by version or platform.
- Your known data arranged in two columns: one for X values (sorted ascending) and one for Y values.
- A target X value for which you want to estimate the corresponding Y.
Step-by-Step
- Set up your data. Put your known X values in column A (e.g., A2:A10) and known Y values in column B (B2:B10). Ensure X values are sorted from smallest to largest. Enter your target X in a separate cell, say D2.
- Find the lower bound. Use
=MATCH(D2, A2:A10, 1)to get the position of the largest X less than or equal to your target. If your target is smaller than the smallest X, this returns an error; handle that separately. - Find the upper bound. The next position is simply the lower bound + 1, but ensure it doesn't exceed the data range. Use
=MIN(lower_bound+1, COUNT(A2:A10)). - Extract the four surrounding values. Using INDEX with the positions from steps 2 and 3:
- x1 =
=INDEX(A2:A10, lower_bound) - y1 =
=INDEX(B2:B10, lower_bound) - x2 =
=INDEX(A2:A10, upper_bound) - y2 =
=INDEX(B2:B10, upper_bound)
- x1 =
- Apply the interpolation formula. In a new cell, enter:
=y1 + (D2 - x1) * (y2 - y1) / (x2 - x1). Replace y1, x1, y2, x2 with the cell references from step 4. This gives the linearly interpolated Y for your target X. - Alternative: use FORECAST.LINEAR for a global linear fit. If your data is roughly linear overall, you can skip the piecewise steps and use
=FORECAST.LINEAR(D2, B2:B10, A2:A10). Note this fits a single straight line through all points, not just the two nearest—use it only when that assumption holds. - Test with a known point. Set D2 equal to one of your known X values; the formula should return the corresponding Y exactly. If it doesn't, check your ranges and sorting.
Common Mistakes
- Unsorted X values. MATCH with match_type 1 requires ascending order. If your X column is not sorted, you'll get wrong positions or errors.
- Using FORECAST.LINEAR for piecewise interpolation. FORECAST.LINEAR fits one line through all points; it does not interpolate between the two nearest points. For piecewise, use the INDEX/MATCH method.
- Forgetting to handle targets outside the data range. If your target X is below the minimum or above the maximum, the formula may return an error or extrapolate incorrectly. Add an IF statement to flag out-of-range targets.
- Mismatched ranges. Ensure the known_x and known_y ranges are the same size and aligned row by row.
- Division by zero. If x1 equals x2 (duplicate X values), the formula divides by zero. Remove duplicates or handle with IFERROR.
Tips
- Use named ranges (Formulas > Name Manager) to make formulas easier to read and less error-prone.
- Wrap the interpolation formula in IFERROR to display a friendly message like "Out of range" instead of #DIV/0! or #N/A.
- For multiple targets, set up a helper column with the lower bound and upper bound for each target, then drag the formula down.
- If you need to interpolate many values, consider using the TREND function for linear regression, but remember it's not piecewise.
- Always plot your data to visually confirm linearity before relying on FORECAST.LINEAR.
Troubleshooting
If your formula returns #N/A, check that the target X is within the range of your known X values. If it returns #VALUE!, verify that all referenced cells contain numbers, not text. If the result is wildly off, confirm that your X values are sorted ascending and that you used the correct match_type (1 for ascending). If you see #DIV/0!, you likely have duplicate X values causing x1 = x2; remove duplicates or adjust the formula to handle that case. For FORECAST.LINEAR errors, ensure the known_y and known_x ranges are the same size and contain no blanks or text. If the interpolation seems inaccurate, double-check that you're using the two nearest points—not the global fit—when the relationship is not linear overall.
Frequently Asked Questions
Can I interpolate without sorting my X values?
No, the MATCH-based method requires ascending X values. If your data is unsorted, either sort it or use a more complex array formula with SMALL and IF to find the nearest points, but sorting is simpler.
What's the difference between FORECAST.LINEAR and the INDEX/MATCH method?
FORECAST.LINEAR fits a single straight line through all your data points (linear regression). The INDEX/MATCH method performs piecewise linear interpolation between the two points that bracket your target X, which is more accurate when the relationship is not perfectly linear.
Can I interpolate with dates in Excel?
Yes, as long as Excel recognizes the dates as serial numbers. Use the same formulas; just format the result as a date if needed.
How do I handle a target X that is exactly equal to a known X?
The formula will return the corresponding Y exactly, because the interpolation weight becomes zero or one. No special handling is needed.
Is there a built-in interpolation function in Excel?
No, Excel does not have a dedicated INTERPOLATE function. You must use FORECAST.LINEAR, TREND, or a custom formula as described above.
Can I use this method for extrapolation?
Yes, but be cautious: extrapolation beyond the known range can be unreliable. The formula will still compute a value, but it assumes the linear trend continues, which may not be valid.