How to Do a Regression in Excel: A Full Guide

To do a regression in Excel, turn on the Analysis ToolPak, then go to Data > Data Analysis and choose Regression. Select your Y range and X range, pick an output location, and select OK. Excel returns the coefficients, R Square, and other statistics in a new table.
This guide covers three ways to run a regression in Excel: the Analysis ToolPak, the LINEST function, and a chart trendline. It also walks through a full example, explains how to read the output, and shows a faster way to test relationships in large files. Details come from Microsoft's support pages, read on November 12, 2026.
What a regression tells you
A regression measures how one value changes when another value changes. The value you want to explain is the dependent variable, or Y. The values you think drive it are the independent variables, or X.
Microsoft describes the Regression tool this way. It "performs linear regression analysis by using the "least squares" method to fit a line through a set of observations."
That line has a simple equation. Microsoft writes it as y = mx + b, where m is the slope and b is the intercept. With more than one X, the equation becomes y = m1x1 + m2x2 + ... + b.
In business terms, a regression answers questions like these:
- How much do sales rise for each extra month of growth?
- How much does ad spend relate to sign-ups?
- How much of the change in cost is explained by order volume?
Microsoft's own example is about athletes. It says you can analyze "how an athlete's performance is affected by such factors as age, height, and weight."
A regression shows association, not proof of cause. A strong line between two values can still come from a third factor you did not measure.
Set up your data in Excel
Regression needs clean, matched pairs of numbers. Each row should hold one observation, with Y in one column and each X in its own column.
Here is the data from Microsoft's simple linear regression example. It lists six months of sales, in dollars.
| Month | Sales |
|---|---|
| 1 | 3,100 |
| 2 | 4,500 |
| 3 | 4,400 |
| 4 | 5,400 |
| 5 | 7,500 |
| 6 | 8,100 |
Put Month in column A and Sales in column B, with headers in row 1. The examples below use this layout. The data then sits in rows 2 to 7, which is why the formulas below use those ranges.
A few rules keep the results trustworthy:
- No blank cells. Every row needs both a Y and an X value.
- Numbers only. Values stored as text will cause errors.
- Enough rows. Six rows work for a demo, but real analysis needs many more.
- One row per observation. Do not mix monthly and weekly rows in one range.
Turn on the Analysis ToolPak
The Regression tool lives in the Analysis ToolPak, an add-in that ships with Excel. You may need to turn it on first.
Microsoft's steps for Excel on Windows are:
- Select File, then Options, and then select Add-Ins.
- In the Manage box, select Excel Add-ins and then select Go.
- In the Add-Ins box, select the Analysis ToolPak check box, and then select OK.
On a Mac, Microsoft says to go to Tools > Excel Add-ins from the file menu. If the ToolPak is not listed, select Browse to find it.
Once it is on, you will see Data Analysis on the Data tab. Microsoft notes that if the command is missing, "you need to load and activate the Analysis ToolPak add-in program."
Way 1: Run a regression with the Analysis ToolPak
This is the most complete method. It gives a full summary table in one step.
- Go to the Data tab and select Data Analysis.
- Choose Regression from the list and select OK.
- In Input Y Range, select the Sales column, including the header.
- In Input X Range, select the Month column, including the header.
- Check Labels, since both ranges include headers.
- Choose an Output Range or a New Worksheet Ply.
- Select OK.
Excel builds a summary with three blocks: regression statistics, an ANOVA table, and a coefficients table. The next section explains how to read them.
For multiple regression, select several adjacent X columns in step 4. Microsoft notes the tool can analyze "how a single dependent variable is affected by the values of one or more independent variables."
Under the hood, the tool uses a worksheet function. Microsoft says "The Regression tool uses the worksheet function LINEST."
Way 2: Use the LINEST function
LINEST gives the same numbers as a formula. It suits people who want results that update when the data changes.
Microsoft's syntax is LINEST(known_y's, [known_x's], [const], [stats]). Known_y's is the Sales range, and known_x's is the Month range.
For the sales data, type this in an empty cell:
=LINEST(B2:B7, A2:A7)
The function returns two values: the slope, then the intercept. Microsoft says the array LINEST returns is "{mn,mn-1,...,m1,b}," so the intercept always comes last.
To get more statistics, set the last argument to TRUE:
=LINEST(B2:B7, A2:A7, TRUE, TRUE)
With stats set to TRUE, LINEST returns standard errors, R squared, the F statistic, degrees of freedom, and sums of squares. Microsoft notes the function "must be entered as an array formula," since it returns several values at once.
Microsoft's page also shows a one-cell forecast. The formula below estimates month 9 sales from months 1 to 6:
=SUM(LINEST(B2:B7, A2:A7)*{9,1})
Microsoft's result for this example is 11,000.
Way 3: Add a trendline to a scatter chart
A trendline shows the regression line on a chart. It is the quickest way to see whether a straight line fits.
- Select both columns of data.
- Insert a scatter chart.
- Select the chart, then add a Trendline from the chart elements menu.
- Open the Format Trendline pane and keep the Linear option.
- Check the boxes to show the equation and the R-squared value on the chart.
The chart then prints the equation, such as y = 1000x + 2000, next to the line. That matches the LINEST result for the sales data.
Trendlines can also project ahead. Microsoft says you can "Set a value in the Forward and Backward fields to project your data into the future."
A trendline is good for a quick look or a slide. For standard errors, p-values, or several X variables, use Way 1 or Way 2.
Which method to use
Each method suits a different job. Pick based on what you need to show and who will read it.
| Method | Best for | Gives p-values | Updates with data |
|---|---|---|---|
| Analysis ToolPak | A full report on one model | Yes | No, rerun the tool |
| LINEST | Models inside a working spreadsheet | No, but gives the statistics to compute them | Yes |
| Scatter trendline | A quick visual check or a slide | No | Yes |
Use the ToolPak when you need to defend a result in a meeting. Its summary table has every number a reviewer may ask about, including p-values for each coefficient.
Use LINEST when the model feeds other formulas, such as a forecast sheet. Because it is a formula, the slope and intercept change as soon as new rows arrive.
Use a trendline when the audience needs to see the pattern. A chart with the line and its equation is easier to read than a table. Many analysts use all three: a trendline to explore, LINEST to build, and the ToolPak to report.
A regression example
Here is what the three methods return for the six months of sales.
| Statistic | Value | What it means |
|---|---|---|
| Slope (m) | 1,000 | Sales rise by about 1,000 per month |
| Intercept (b) | 2,000 | The line's value at month 0 |
| R squared | 0.93 | About 93% of the variation in sales follows the monthly trend |
| Month 9 estimate | 11,000 | 1,000 × 9 + 2,000 |
You can check the slope by hand. The average month is 3.5 and the average sales value is 5,500. The slope is the sum of the cross-products of deviations divided by the sum of squared month deviations. That works out to 17,500 divided by 17.5, which is 1,000.
The intercept then follows. It is the average sales value minus the slope times the average month: 5,500 minus 3,500, which is 2,000.
R squared tells you how well the line fits. Microsoft describes it as a value that "ranges in value from 0 to 1." At 1, the line fits every point. At 0, Microsoft says "the regression equation is not helpful in predicting a y-value."
How to read the regression output
The Analysis ToolPak output can look dense. Most decisions rest on a handful of numbers.
- Multiple R. The correlation between actual and predicted values. Closer to 1 means a tighter fit.
- R Square. The share of the variation in Y explained by X. Here it is about 0.93.
- Adjusted R Square. R Square adjusted for the number of X variables. Use it when comparing models with different numbers of inputs.
- Standard Error. The typical distance between actual points and the line.
- Coefficients. The intercept and the slope for each X. These build your equation.
- P-value. The chance of seeing a coefficient this large if the true effect were zero. Many analysts treat values below 0.05 as significant.
- F and Significance F. A test of the whole model. A small Significance F suggests the model explains more than chance.
Microsoft adds a note on accuracy. It says "The more linear the data, the more accurate the LINEST model."
Read the coefficients in plain units. A slope of 1,000 means each extra month adds about 1,000 in sales, on average, over this period.
Do a regression in Excel with AI
When you have many columns and are not sure which ones matter, testing each pair by hand takes time. An AI tool can check relationships across a dataset and explain them.
Here is the method in three steps, using Powerdrill Bloom.
Step 1: Upload your Excel file
Upload the workbook with your Y column and your candidate X columns. The Excel Calculations page asks you to upload the workbook first. It adds: "Ensure your data is correctly formatted to enable smooth calculations."
Keep one row per observation and clear column headers. The AI uses the headers to understand what each column means.
Step 2: Ask for the analysis in natural language
Describe what you want to test. For example: "Run a linear regression of sales on month and ad spend, and explain which one matters more."
The same page says you can "Input your desired calculation request in text." Ask follow-up questions, such as whether a relationship still holds when you drop one outlier month.
Step 3: Check the results and chart them
Check the slope against LINEST in your own workbook. Then show the relationship visually. The Scatter Graph Creator is built to "visualize data relationships with interactive and customizable scatter plots."
For projections that go beyond a straight line, the AI Forecasting tool builds forecast charts with confidence bands. For background on the method itself, see our explainer on regression analysis.
Common mistakes to avoid
These are the errors that come up most often when people run a regression in Excel.
- Mixing up X and Y. Y is the value you want to explain. Swapping them changes the slope.
- Forgetting the Labels box. If your ranges include headers, check Labels, or Excel reads the header as data.
- Running regression in Excel for the web. Microsoft says you "can't create a regression analysis" there, because the Regression tool is not available. Use the desktop app.
- Reading R Square alone. A high R Square does not prove cause, and it can hide a curved pattern. Always look at the scatter chart.
- Using too few rows. Six points can produce a neat line by chance. More data gives a more reliable result.
- Extrapolating too far. A line fitted on months 1 to 6 may not hold for month 24.
- Ignoring outliers. One unusual month can pull the whole line. Check the chart for points far from the rest.
- Adding many related X columns. Inputs that move together make coefficients unstable. Microsoft notes LINEST "checks for collinearity" and removes redundant X columns.
When you are ready to test relationships across a whole dataset, try Powerdrill Bloom with last year's monthly figures.
Frequently asked questions
How do I do a simple linear regression in Excel?
Turn on the Analysis ToolPak, go to Data > Data Analysis, and choose Regression. Select your Y and X ranges, check Labels if you included headers, and select OK. You can also use =LINEST(Y range, X range).
Can I do a regression in Excel for the web?
Not fully. Microsoft says you can view regression results in Excel for the web, but you can't create a regression analysis there. Open the file in the desktop app to run it.
What does R squared mean in Excel regression?
R squared shows how much of the variation in Y the line explains. It ranges from 0 to 1. A value of 0.93 means about 93% of the variation follows the fitted line.
How do I do a multiple regression in Excel?
Put each X variable in its own adjacent column. In the Regression tool, select all the X columns as the Input X Range. LINEST also accepts several X columns.
What is the difference between LINEST and the Regression tool?
They give the same coefficients. Microsoft says the Regression tool uses LINEST. The tool writes a full summary table, while LINEST returns the numbers as a formula that updates with your data.
Sources: Microsoft Support, Use the Analysis ToolPak to perform complex data analysis · Microsoft Support, LINEST function · Microsoft Support, Perform a regression analysis · Microsoft Support, Add a trend or moving average line to a chart.