How to Run Regression in Excel: LINEST and Analysis ToolPak – LicenceHouse guide

To run regression in Excel, load the Analysis ToolPak (File > Options > Add-ins > Excel Add-ins > Go), then choose Data > Analysis > Data Analysis > Regression. Set the Input Y Range to the values you want to predict and the Input X Range to the predictors, then select OK. For a live formula instead, use =LINEST(known_y's, known_x's, TRUE, TRUE).

Approach Best for Updates when data changes?
Analysis ToolPak > Regression A full report with ANOVA, p-values and residuals No, rerun it
LINEST Coefficients and statistics in cells Yes
SLOPE, INTERCEPT, RSQ Quick single-predictor results Yes
Chart trendline Visual fit with equation and R² Yes

How do I add the Analysis ToolPak in Excel?

The Excel Analysis ToolPak is a free add-in that ships with Excel but is switched off by default. To add it on Windows:

  1. Go to File > Options and select Add-ins.
  2. In the Manage box at the bottom, choose Excel Add-ins and select Go.
  3. Tick Analysis ToolPak and select OK. If Excel says it isn't installed, select Yes to install it.
  4. A Data Analysis button now appears in the Analysis group at the right of the Data tab.

On a Mac, go to Tools > Excel Add-ins, tick Analysis ToolPak and select OK. Microsoft's guide to how to load the Analysis ToolPak lists it for Excel 2021, Excel 2024 and Microsoft 365 on both Windows and Mac. It's also part of Excel 2016 and 2019. The Regression tool isn't available in Excel for the web.

How do I do regression analysis in Excel?

With the ToolPak loaded, choose Regression from the Data Analysis list and point it at your data. Here's a worked example: monthly advertising spend (in thousands) against sales (in thousands of units).

Running Excel's Regression tool on ad spend and sales: Input Y Range $B$1:$B$9, Input X Range $A$1:$A$9, Labels ticked, then OK.

Row A (Ad spend) B (Sales)
1 Ad spend Sales
2 1 12
3 2 15
4 3 21
5 4 24
6 5 30
7 6 31
8 7 37
9 8 41
  1. Go to Data > Data Analysis, choose Regression and select OK.
  2. Input Y Range: $B$1:$B$9 (the outcome).
  3. Input X Range: $A$1:$A$9 (the predictor). For several predictors, select adjacent columns, such as A1:C9.
  4. Tick Labels, because row 1 holds headings.
  5. Leave Constant is Zero clear unless theory says the line must pass through zero.
  6. Choose New Worksheet Ply for the output, and tick Residuals and Line Fit Plots if you want them.
  7. Select OK.

For this data, the output shows an intercept of about 7.68, an Ad spend coefficient of about 4.15 and an R Square of about 0.991. So each extra thousand spent is associated with roughly 4,150 more units sold. Spending 10 thousand would predict about 4.15 × 10 + 7.68 = 49.2 thousand units.

How do I read the regression output?

The report has three blocks. Focus on these values:

  • R Square: the share of variation in Y explained by the model, from 0 to 1. Use Adjusted R Square when comparing models with different numbers of predictors.
  • Significance F: the p-value for the model as a whole. Below 0.05 is the usual threshold.
  • Coefficients: the intercept and the slope for each predictor. This is your equation.
  • P-value per coefficient: whether that predictor adds anything beyond chance.
  • Lower 95% / Upper 95%: the confidence interval for each coefficient.

What we commonly see: a high R Square on a time series, where both columns simply grow over time, gets read as proof that one causes the other. Regression only measures association. Plot the residuals (tick Residual Plots) and look for patterns. A curve or funnel shape means a straight line isn't the right model. The scatter plot guide linked below shows how to chart the raw data first.

How do I use the LINEST function in Excel?

The LINEST function returns the regression coefficients, and optionally the full statistics, as a formula that recalculates when the data changes. Its syntax is LINEST(known_y's, [known_x's], [const], [stats]).

LINEST formula =LINEST(B2:B9,A2:A9,TRUE,TRUE) explained by argument, giving slope 4.15 and intercept 7.68 for the sample data.

=LINEST(B2:B9,A2:A9)              returns slope and intercept
=LINEST(B2:B9,A2:A9,TRUE,TRUE)    returns a 5-row block of statistics
=INDEX(LINEST(B2:B9,A2:A9),1)     slope only (4.15)
=INDEX(LINEST(B2:B9,A2:A9),2)     intercept only (7.68)

In Excel 2021, 2024 and Microsoft 365, enter it in one cell and the results spill. In Excel 2019 and 2016, first select the output range (2 columns × 5 rows for one predictor), type the formula and press Ctrl+Shift+Enter to enter it as an array formula. For simpler single-predictor work, =SLOPE(B2:B9,A2:A9), =INTERCEPT(B2:B9,A2:A9) and =RSQ(B2:B9,A2:A9) return the same numbers one at a time.

What does the LINEST output in Excel mean?

With stats set to TRUE, LINEST returns a block of five rows. Microsoft's LINEST function reference documents the layout:

LINEST statistics layout: slope and intercept, standard errors, R squared, F statistic, degrees of freedom and sums of squares.

Row Column 1 Column 2
1 Slope (m) Intercept (b)
2 Standard error of slope Standard error of intercept
3 R² Standard error of the Y estimate
4 F statistic Degrees of freedom
5 Regression sum of squares Residual sum of squares

Advanced nuance: with several predictors, LINEST returns the coefficients in reverse order. If X is in columns A, B and C, row 1 reads mC, mB, mA, b. Rows 3 to 5 only fill the first two columns, and the rest show #N/A. That's expected, not an error. Wrap the formula in IFNA(…,"") for a cleaner display.

How do I do polynomial regression in Excel?

Raise the X values to several powers inside LINEST, using an array constant. For a quadratic (second-order) fit:

=LINEST(B2:B9,A2:A9^{1,2})
=LINEST(B2:B9,A2:A9^{1,2,3},TRUE,TRUE)   cubic, with statistics

The quadratic formula returns three values: the x² coefficient, the x coefficient and the intercept. For the sample data that's about −0.018, 4.315 and 7.411. The tiny x² term confirms that a straight line already fits well. With the ToolPak, add helper columns instead, such as =A2^2 in column C, and use A:C as the Input X Range.

For a quick visual check, chart the data, add a trendline and choose Polynomial with an order of 2 to 6, then tick Display Equation on chart. Our guide to adding a line of best fit covers trendline options, and the scatter plot guide shows how to build the chart first.

Which Excel version do I need for regression?

LINEST, SLOPE, INTERCEPT and the Analysis ToolPak are in every desktop version from Excel 2016 onwards, on Windows and Mac. Newer versions make LINEST easier, because dynamic arrays (Excel 2021, 2024 and Microsoft 365) spill its output without Ctrl+Shift+Enter. Excel 2021 support ended on 13 October 2026, so Excel 2024 is the current perpetual option, supported until October 2029. Python in Excel, which brings statistics libraries into the grid, is Microsoft 365 only. See our comparison of Excel 2024 and Excel 365 and the Office 2024 collection.

Frequently asked questions

Why don't I see Data Analysis on the Data tab?

The Analysis ToolPak isn't loaded. Go to File > Options > Add-ins, choose Excel Add-ins in the Manage box, select Go and tick Analysis ToolPak. If it still doesn't appear, check that the add-in isn't listed under Disabled Items in the same Manage box, and restart Excel after enabling it.

How many X variables can Excel regression handle?

LINEST accepts many predictor columns, limited mainly by having more rows than predictors. The Analysis ToolPak's Regression tool has a lower limit and accepts up to 16 X columns in a single run. Both need the X columns to sit next to each other, so rearrange your data or use helper columns if they don't.

Why does LINEST return #VALUE! or #REF!?

#VALUE! usually means the Y and X ranges have different numbers of rows, or one contains text or blank cells. #REF! can appear in older versions when the array formula's output range is too small. Clean the data, make both ranges the same height, and in Excel 2019 or 2016 select a big enough range before pressing Ctrl+Shift+Enter.

How do I predict new values from the regression?

Use =FORECAST.LINEAR(x, known_y's, known_x's) for one predictor, for example =FORECAST.LINEAR(10,B2:B9,A2:A9). For several predictors, use TREND, or multiply each coefficient from LINEST by its X value and add the intercept. Predictions far outside your data range are much less reliable.

Is Excel accurate enough for regression?

For typical business and coursework data, yes. LINEST and the ToolPak use least squares, the standard method. For very large data, complex models such as logistic regression, or specialist diagnostics, use dedicated statistics software, or Python in Excel if you have Microsoft 365.

Related guides

Links in this guide

Link Type Why it helps
Microsoft Support: Load the Analysis ToolPak External Official add-in steps and supported versions
Microsoft Support: LINEST function External Syntax and statistics layout
Line of best fit in Excel Internal Trendlines and polynomial fits on charts
Scatter plot in Excel Internal Chart the data before modelling
Excel 2024 vs Excel 365 Internal Python in Excel and other 365-only tools
Office 2024 collection Internal Current perpetual Office editions
Average of averages Internal Avoid a common statistics mistake
Error bars in Excel Internal Show uncertainty on charts
Exponents and scientific notation Internal Powers used in polynomial terms
Axis titles and legends Internal Label regression charts clearly
Data analysis, Excel, Excel formulas, How-to