Yes. In Excel for Microsoft 365 on Windows, create or select an XY scatter chart, then choose Chart Design > Add Chart Element > Trendline > Linear to add a regression line. You can also display its equation and R-squared value from the trendline’s formatting options, which helps explain what the line says about your data.
What a regression line shows
A linear regression line is a straight line that summarizes the relationship between two numeric variables. Excel’s linear chart trendline uses the least-squares method: it chooses the line that minimizes the sum of the squared vertical differences between the observed data points and the line’s predicted values. The line is commonly written as y = mx + b. Here, m is the slope, or the predicted change in y for a one-unit increase in x, and b is the y-intercept, the predicted y value when x is zero.
For example, a chart of hours studied against exam scores might show an upward-sloping line. That indicates that higher study hours tend to occur alongside higher scores in the data. It does not prove that studying alone caused the scores to rise; other factors may contribute. A trendline is a compact description of an association, not an explanation of its cause.
Prepare the data and choose the right chart
For a straightforward regression line, arrange the independent variable (x) in one column and its paired outcome (y) in another. Keep each observation on the same row, use numeric values, and label the columns. For example, list advertising spend in A and sales in B, with each row representing the same time period. Avoid blank or text entries among the observations unless you have checked how Excel handles them.
An XY scatter chart is usually the right chart because it treats the horizontal values as numbers and places points according to their actual x-values. A standard line chart often treats its horizontal axis as categories, spacing entries evenly even when the underlying values are unevenly spaced. That can make a fitted line misleading if your x-values represent quantities such as time elapsed, distance, or price.
To create a scatter chart, select the paired data, including the headings, and choose Insert > Insert Scatter (X, Y) or Bubble Chart > Scatter. Choose a marker-style scatter chart for separate observations. If you already have a suitable scatter chart, you do not need to rebuild it; select the chart and add the trendline.
Add a linear trendline in Excel
- Select the scatter chart, then click a data point in the series you want to model. Check that the whole series is selected rather than just one point.
- Choose Chart Design > Add Chart Element > Trendline > Linear. Excel adds a straight line fitted to that series.
- To adjust the line or display statistics, choose Chart Design > Add Chart Element > Trendline > More Trendline Options. In the Format Trendline pane, confirm that Linear is selected and use the options to show the equation or R-squared value on the chart.
- Move the equation or statistic label if it covers a point. Click the label and drag it to a clearer location.
You can also right-click the data series and choose Add Trendline, then select Linear in the pane. The Chart Design tab appears when the chart is selected. On Excel for Mac, the chart-element commands are also available from the Chart Design tab, although their layout can vary slightly by release. Excel for the web has fewer chart-formatting controls in some versions; if you cannot find the trendline options, open the workbook in the desktop Excel app.
Show the equation and R-squared
In the Format Trendline pane, select Display Equation on chart to place the fitted formula on the plot, and select Display R-squared value on chart to show a fit statistic. The displayed equation is useful for a quick explanation or visual check. It may be rounded for display, so use worksheet calculations or increase the displayed precision if you need more accurate predictions.
R-squared describes how much of the variation in the observed y-values is accounted for by the fitted model in this sample. It ranges from 0 to 1 for the usual linear regression with an intercept: a value nearer 1 indicates a closer fit to these points. It does not establish that the relationship is causal, that the model will predict new data well, or that the chosen model is appropriate. An unusual outlier can also affect both the line and the statistic.
Check the result with worksheet formulas
Worksheet functions are useful when you want the fitted coefficients in cells, rather than only as chart labels. Suppose A2:A6 contains x-values 1, 2, 3, 4, 5 and B2:B6 contains y-values 3, 5, 4, 6, 7. The line for this example is y = 0.9x + 2.3. With y-values in B2:B6 and x-values in A2:A6, enter:
- For the slope:
=SLOPE(B2:B6,A2:A6)returns 0.9. - For the intercept:
=INTERCEPT(B2:B6,A2:A6)returns 2.3. - For R-squared:
=RSQ(B2:B6,A2:A6)returns 0.91.
The results can be checked directly: the fitted values at x = 1 through 5 are 3.2, 4.1, 5.0, 5.9, and 6.8. The squared residuals add to 0.9, while the total squared deviations of the observed y-values from their mean add to 10; therefore R-squared is 1 − 0.9/10 = 0.91. With the same x and y ranges, predicting y at x = 6 using =FORECAST.LINEAR(6,B2:B6,A2:A6) returns 7.7. This is an extrapolation beyond the observed x-values, so it should not be treated as a guaranteed outcome.
Choose a trendline that fits the pattern
Linear is a sensible starting point when the relationship appears roughly straight across the range of interest. Excel offers other trendline types in the Format Trendline pane, including exponential, logarithmic, polynomial, and power. The type should follow the shape and context of the data, not just whichever option gives the largest R-squared.
- Linear: a constant estimated change in y per unit of x.
- Exponential: a curved pattern that grows or declines at a rate proportional to its current level; it has restrictions, such as requiring positive y-values for Excel’s standard exponential fit.
- Logarithmic: a pattern that changes quickly at first and then levels off; it requires positive x-values.
- Polynomial: a flexible curve that can turn; increasing its order can fit the existing points closely while making extrapolation unstable.
- Power: a curved relationship where y varies with a power of x; it requires positive x- and y-values.
Compare the fitted curve with the plotted points and ask whether its shape makes sense for the process. A higher-order curve can look impressive while encoding noise rather than a reliable relationship. If you need a model with several explanatory variables, a single chart trendline is not multiple regression; use Excel’s Analysis ToolPak regression tool or suitable statistical software instead.
Interpretation, limitations, and common problems
Read the slope in the units of your variables. If x is measured in dollars and y in units sold, a slope of 0.9 means the fitted sales value rises by 0.9 units for each additional dollar of x, on average within the model. It does not mean every observed row follows that change. The intercept may have little practical meaning when x = 0 is outside the range of the data.
If Excel adds a line that looks wrong or does not match your expectation, check these common causes:
- Wrong chart type: use an XY scatter chart for numeric x-values rather than assuming a line chart’s category axis represents numeric spacing.
- Wrong series: verify that the selected trendline belongs to the intended data series. A chart with multiple series can have a separate trendline for each one.
- Rows do not pair correctly: make sure each x-value and y-value describe the same observation, and that the selected ranges have matching lengths.
- Text or missing values: inspect cells that look numeric but are stored as text, and decide how to handle missing observations before fitting.
- Misleading scale or outlier: inspect the axes and points. A single extreme observation can pull the least-squares line away from the main cluster.
Do not use a line to imply certainty. Predictions are most defensible within a range represented by the observations; extrapolation outside that range assumes the same pattern continues. Also consider whether the points show a curve, clusters, or changing spread around the line. A visually neat line and high R-squared do not replace checking residuals, measurement quality, or the real-world meaning of the variables.
Frequently Asked Questions
Can Excel add a regression line to a line chart?
Excel can add a trendline to eligible chart series, but a line chart’s horizontal axis may be categorical rather than a true numeric scale. For regression between two numeric variables, use an XY scatter chart. It plots the actual x-values and is generally the clearer choice.
How do I show the regression equation on my Excel chart?
Select the chart series and add a trendline, then open More Trendline Options. In the Format Trendline pane, select Display Equation on chart. The equation is rounded for display, so rely on worksheet functions such as SLOPE and INTERCEPT when you need full calculation precision.
What does the R-squared value mean in Excel?
For a fitted linear trendline, R-squared indicates the share of variation in the sample’s y-values accounted for by the model. A high value does not prove causation or guarantee accurate future predictions. Review the scatter of points and the context before drawing conclusions.
Why is the trendline missing from Excel?
Confirm that you selected a chart series and that the chart type supports the trendline option. The command may also be in More Trendline Options rather than the first menu. If you are using Excel for the web and cannot access the required controls, try the desktop app.
Can Excel make a regression line for multiple variables?
A chart trendline models one y-variable against one x-variable at a time. To estimate a model with multiple predictors, use the Regression tool in Excel’s Analysis ToolPak, if that add-in is enabled, or another statistical method. Do not interpret several separate chart lines as one multiple-regression model.
Related
- Excel Data Validation: Create a Filtered Dropdown List
- Excel Data Table Image: Convert Pictures to Cells
- Excel PivotChart Without a PivotTable: What Actually Works
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Outlook Never Block Sender: Why Mail Still Goes to JunkChoosing Never Block Sender in Outlook adds an address to your Safe Senders list; it does not guarantee…
- Creating a Fillable Form in Word: Steps and Tips That WorkTo create a fillable form in Microsoft Word for Microsoft 365 on Windows, turn on the Developer tab,…
- Google Sheets Conditional Formatting: How to Apply RulesYes. Google Sheets includes conditional formatting, which automatically changes a cell’s appearance when its value or a formula…
- Change Google Sheets Date Format to AustraliaTo use Australian dates in Google Sheets, open the spreadsheet in a browser and choose File > Settings.…
- Delete Duplicates in Google Sheets: Safe MethodsTo delete duplicate rows in Google Sheets, select your data, then choose Data > Data cleanup > Remove…
- Create a Default Signature in Outlook: Step-by-StepTo create a default signature in Outlook, open the signature settings for your version, create and format the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.