Linear Regression in Excel with LINEST, SLOPE and FORECAST β€” No Add-ins

⏱ 2 min readUpdated 27 September 2026

The simplest machine-learning model is a straight line through your data. Excel can fit it with plain formulas β€” no Analysis ToolPak needed.

In this article
  1. Example: ad spend vs sales
  2. LINEST: everything at once
  3. Reading the result sensibly

Example: ad spend vs sales

Put monthly ad spend in B2:B25 (x) and sales in C2:C25 (y).

“`excel
=SLOPE(C2:C25, B2:B25) ‘ extra sales for each extra β‚Ή1 of ads
=INTERCEPT(C2:C25, B2:B25) ‘ predicted sales with zero ad spend
=RSQ(C2:C25, B2:B25) ‘ 0-1: how much of the variation the line explains
=FORECAST.LINEAR(50000, C2:C25, B2:B25) ‘ predicted sales at β‚Ή50,000 spend
“`

LINEST: everything at once

“`excel
=LINEST(C2:C25, B2:B25, TRUE, TRUE)
“`

In Excel 365 this spills a 5Γ—2 block of statistics: slope and intercept in the first row, their standard errors in the second, RΒ² in the third, then the F statistic and sums of squares. For several inputs (ad spend and discount %), pass a multi-column x range: =LINEST(D2:D25, B2:C25, TRUE, TRUE). Note that LINEST returns the coefficients in reverse column order.

Reading the result sensibly

  • RΒ² of 0.8 means the line explains 80% of the ups and downs β€” it does not prove ads cause sales.
  • Predict only inside the range you have data for. A line fitted on β‚Ή10k–₹60k spends says nothing reliable about β‚Ή5 lakh.
  • Always chart it: Insert β†’ Scatter, then Add Trendline β†’ Display equation and RΒ². One outlier can drag the whole line.
πŸ’‘ TREND returns fitted values for a whole column at once β€” =TREND(C2:C25, B2:B25) β€” handy for a “predicted vs actual” chart.

Want to see how the computer actually finds that line? Read linear regression from scratch in Python.