How to Add a Linear Regression Trendline to an Excel Scatter Plot

·
9 min read

Online Tech Tips is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

You’re either here because you searched for how to add a linear regression trendline to an Excel scatter plot. Or you saw the title and thought, “Are these words even English?” Either way, you’re in the right place.

Hoping this is simpler than it sounds? It mostly is. Excel handles the hard math, you just need to know which buttons to click. And by the end, you’ll have a chart that actually tells you something useful.

What Is Linear Regression?

Already know what a linear regression trendline is? Skip ahead to the step-by-step section. For everyone else, here’s the short version.

Linear means in a line. You knew that. Regression, in math, means figuring out how much one thing depends on another thing. We’ll call those two things X and Y.

A good example: tracking the value of a single stock over the years. X is time in years. Y is the value in dollars.

We know time affects stock price, but how much? If a stock jumped from $1 to $100 in one year, will it be worth $2,500 in 25 years? Not necessarily. That’s where regression helps.

Stock chart showing value over time

Here’s the idea: record the stock’s value each year, plot those data points on a chart, and draw a straight line through the scatter of dots that best represents the overall trend. That line is the linear regression trendline. The chart is the scatter plot, named because the dots are scattered based on your X and Y values.

Chart with magnifying glass examining data points

Now those words are just words. Let’s build one in Excel.

Before You Begin

Make sure you have:

  • A computer running Windows 10/11 or macOS (Sonoma or later)
  • Microsoft 365 or Excel 2021 installed, the desktop version gives you the full set of options
  • Two columns of numeric data, one for X values and one for Y values

The steps below cover both Windows and macOS. Where they differ, we’ll say so.

How to Create an Excel Scatter Plot With a Linear Regression Trendline

Step 1: Set Up Your Data

Put your X values in one column and your Y values in the next, with matching pairs on the same row. Add headers in the first row, something like “Time (Yrs)” and “Stock Value ($)”, and Excel will use them to label the chart automatically.

Here’s the sample data we’ll use. You can copy and paste the data into Excel and follow along:

Time (Yrs)Stock Value ($)
20001498
20011160
20021147
2003848
20041126
20051180
20061294
20071420
20081322
2009797
20101169
20111325
20121408
20131569
20141872
20152067
20162059
20172362
20182640
20192834
20202584

Step 2: Select Your Data

Click the top-left cell of your data (including the header), hold Shift, then click the bottom-right cell of the right column to highlight both columns.

Step 3: Insert a Scatter Chart

  1. Click the Insert tab in the ribbon.
  2. In the Charts group, find the icon that looks like a cluster of dots, that’s the scatter chart button.
  3. Click the small down arrow next to it.
  4. Select the first option: Scatter (dots only, no connecting lines).
Excel Insert tab with the Charts group visible, showing the Insert Scatter (X, Y) or Bubble Chart dropdown open with the basic Scatter option highlighted

Excel drops a scatter chart onto your sheet. So far so good. Now for the trendline.

Step 4: Add the Linear Trendline

Three ways to do this in current Microsoft 365 and Excel 2021. Pick whichever feels most natural.

Option A: Right-click a data point (quickest)

  1. Right-click any dot on the scatter chart.
  2. Select Add Trendline… from the context menu.
Excel scatter chart showing a right-click context menu on a data point with Add Trendline highlighted

Option B: Chart Elements “+” button

  1. Click the chart to select it.
  2. Click the + button that appears at the upper-right corner of the chart.
  3. Check the box next to Trendline.
Excel scatter chart with the Chart Elements plus button panel open, showing the Trendline checkbox

Option C: Chart Design tab

  1. Click the chart.
  2. Go to the Chart Design tab in the ribbon.
  3. Click Add Chart Element > Trendline > Linear.
Excel Chart Design tab with Add Chart Element dropdown open, showing the Trendline submenu expanded with Linear highlighted

Any of those three methods opens the Format Trendline pane on the right side of the screen. Linear is already selected, just leave it there. Feel free to adjust the line color or style if you want the trendline to stand out more clearly.

Step 5: Display the Equation and R²

  1. In the Format Trendline pane, scroll down to the bottom.
  2. Check Display Equation on chart.
  3. Check Display R-squared value on chart.
Excel Format Trendline pane with Linear trendline option selected and both Display Equation on chart and Display R-squared value on chart checkboxes checked

Your chart now shows something like y = 80.468x − 160136 with R² = 0.69 floating on the chart. If the label overlaps your data points, just click on it and drag it to a clear spot.

Excel scatter chart with a linear regression trendline drawn through the data points and the regression equation plus R-squared value displayed as a label on the chart

Step 6: Forecast Forward (Optional)

Want a rough sense of where this trend is headed, say, in 2030? In the Format Trendline pane, find the Forecast section. Type the number of periods you want to project into the Forward field.

Type 10 for ten more years, and the trendline extends beyond your existing data with a visual estimate.

Excel Format Trendline pane showing the Forecast section with the Forward field set to 10 and the extended trendline visible on the scatter chart beyond the data range

On macOS

The steps are nearly identical on a Mac. The ribbon looks a little different, but all the same options are there:

  1. Select your data and go to Insert > Chart > XY (Scatter) > Scatter.
  2. Click the chart, then click Chart Design in the ribbon.
  3. Click Add Chart Element > Trendline > Linear.
  4. In the Format Trendline pane, check Display Equation on chart and Display R-squared value on chart.
Excel for Mac with a scatter chart selected, showing the Format Trendline pane on the right with Linear selected and the equation and R-squared checkboxes both enabled

What the Equation and R² Actually Mean

The R-squared value (R²) tells you how well the trendline fits your data. It runs from 0 to 1. A value above 0.8 is a strong fit. The 0.69 from our example means the trendline accounts for about 69% of the variation in stock price, pretty solid for a single-variable model, though real stock analysis obviously factors in a lot more.

The equation (in the form y = mx + b) lets you calculate an estimated Y value at any X, including points outside your data range.

Using our sample equation Y = 80.468 × X − 160136, here’s what 2030 looks like:

Y = 80.468 × 2030 − 160136 Y = 163,350.04 − 160,136 Y ≈ $3,214

That’s the trendline’s estimate. Take it as a ballpark. A lot can shift between now and 2030, and a straight line can only tell you so much.

Get Full Regression Statistics With the Analysis ToolPak

The chart equation is convenient, but Excel rounds the displayed coefficients. If you need the complete breakdown, including standard errors, confidence intervals, and precise coefficient values, the Analysis ToolPak add-in gives you all of that in a proper output table.

Step 1: Enable the Analysis ToolPak

  1. Go to File > Options > Add-ins.
  2. At the bottom, set the Manage dropdown to Excel Add-ins and click Go.
  3. Check the box next to Analysis ToolPak and click OK.
Excel Add-ins dialog box with the Analysis ToolPak checkbox selected and the OK button visible

Step 2: Run the Regression

  1. Click the Data tab.
  2. Click Data Analysis on the far right of the ribbon.
  3. Choose Regression and click OK.
  4. Set your Input Y Range (the stock value column) and Input X Range (the time column). Include headers if you check the Labels box.
  5. Choose New Worksheet Ply to send the results to a fresh sheet.
  6. Click OK.
Excel Data Analysis Regression dialog with Input Y Range and Input X Range fields filled in and New Worksheet Ply selected as the output option

You’ll get a full table with the slope, intercept, R², standard error, and more. Much more useful than the rounded chart label when you actually need to present the numbers to someone.

Tips and Troubleshooting

Common Issues

Problem: “Add Trendline” is greyed out or the option is missing

Almost always a chart type problem. Trendlines don’t work on pie charts, stacked charts, or 3D charts. Right-click the chart, choose Change Chart Type, and switch to Scatter (X, Y).

Also: make sure you’re right-clicking directly on a data point. Click the blank chart background by mistake and you’ll get a completely different context menu, with no trendline option in sight.

Problem: The equation or R² isn’t appearing on the chart

Open the Format Trendline pane and confirm both checkboxes are actually ticked, Display Equation on chart and Display R-squared value on chart. If they’re checked but nothing’s visible, the text box is probably hiding behind another chart element. Click around the chart edges to find it.

Problem: The equation doesn’t match my manual calculation

Excel rounds the coefficients in the displayed equation; the underlying math uses more decimal places, so a small gap is expected. For precise values, use the Analysis ToolPak regression output instead, or pull the numbers directly into cells with =SLOPE(Y_range, X_range) and =INTERCEPT(Y_range, X_range).

Problem: My X values are text or dates stored as text

Scatter charts need numeric X values. If Excel treats your X column as text, it’ll handle the chart wrong and the regression won’t make sense. Fix it by selecting the column, right-clicking, choosing Format Cells, and setting the format to Number or Date. Then rebuild the chart from scratch.

Pro Tips

  • Move the equation label: Click the floating equation on your chart and drag it somewhere your data isn’t crowded.
  • Check R² before trusting the line: If R² is below 0.5, a straight line probably isn’t capturing what’s happening in your data. The Format Trendline pane also has Polynomial, Exponential, and Logarithmic options, worth trying when your data curves.
  • Quick coefficient check without running a full regression: Use =SLOPE(Y_range, X_range) and =INTERCEPT(Y_range, X_range) to get exact values in cells you can reference in other formulas.

Other Ways to Do This in 2026

Excel is the obvious choice here, but it’s not the only one:

  • Google Sheets: Free, browser-based, and the workflow is nearly identical. Insert a scatter chart, go to Customize > Series > Trendline, set the type to Linear, and enable the equation display.
  • Excel for the web: Supports scatter charts and trendlines, though the formatting options are thinner than the desktop version. Fine for a quick look, not ideal for presentation-ready charts.
  • Power BI: A better fit for large, connected datasets where you want interactive dashboards and automated data refresh. Scatter charts with trend lines are built right in.
  • Python (matplotlib + scikit-learn): Worth considering for anything you’ll run repeatedly on new data. More setup upfront, but far more control over the output.

For a spreadsheet of data you want to visualize quickly, Excel gets it done without fuss.

Wrapping Up

Adding a linear regression trendline in Excel takes about two minutes once you know the steps. The scatter chart plots your data, the trendline shows the direction, and the equation plus R² tell you how much weight to put behind it.

For everyday data analysis, this is a solid choice, particularly if you’re already working in Excel. The Analysis ToolPak is worth trying when you need numbers you can actually present to someone else, rather than just a visual label floating on a chart.