Excel Trendline Equation in a Cell: How to Get It

Charts & pivot tables · Updated November 21, 2026

Yes—but Excel does not put a chart’s trendline equation into a worksheet cell automatically. For a linear trendline, calculate its slope and intercept with SLOPE and INTERCEPT, then use those values in a cell formula or prediction. This gives you usable numbers, not just the equation label printed on a chart.

What the chart’s trendline equation represents

A trendline is a regression fitted to the data plotted in a chart. For a linear trendline, its equation is usually written y = mx + b: m is the slope, and b is the y-intercept. The slope describes the average change in y for a one-unit increase in x; the intercept is the model’s estimated y value when x is zero.

Excel can show this equation on the chart, but that displayed label is an annotation. It is not a cell reference and cannot be used directly in a worksheet calculation. Also, the label may show rounded coefficients. A chart label that reads “y = 1.92x + 1.04” may hide extra decimal places, so copying those printed numbers into a formula can produce slightly different predictions from the fitted trendline.

For the worksheet calculation to match the chart, use the same x and y observations and the same trendline type. For a linear trendline, worksheet regression functions can return the coefficients at full stored precision. If you need the chart to treat x values as actual numbers, an XY (Scatter) chart is generally the clearest choice.

Calculate a linear trendline’s coefficients

Suppose numeric x values are in A2:A6 and corresponding y values are in B2:B6. The following formulas calculate the linear trendline’s slope and intercept separately. Put them in two cells, such as D2 and D3, and label the results so you can identify them later.

With x values in A2:A6 and y values in B2:B6, enter this in D2 to calculate the slope:

=SLOPE($B$2:$B$6,$A$2:$A$6)

With the same data layout, enter this in D3 to calculate the intercept:

=INTERCEPT($B$2:$B$6,$A$2:$A$6)

For example, if A2:A6 contains 1, 2, 3, 4, 5 and B2:B6 contains 3, 5, 7, 8, 11, the slope is 1.92 and the intercept is 1.04. The fitted equation is therefore y = 1.92x + 1.04. The values in the cells may display more digits than this rounded illustration, depending on their number format.

The order of the arguments matters: both functions take the y values first and the x values second. Keep the ranges the same size and pair each x observation with its corresponding y observation on the same row. Absolute references, shown by the dollar signs, are useful when copying a formula elsewhere because they keep the source ranges fixed.

Build the equation as text in one cell

If you want one cell to display a readable equation, combine the calculated coefficients with TEXT. This creates a text label; it does not create a reusable mathematical formula. The example below also handles a negative intercept so the result displays a minus sign instead of “+ -”.

With x in A2:A6 and y in B2:B6, enter this formula in the cell where you want the equation label:

="y = "&TEXT(SLOPE($B$2:$B$6,$A$2:$A$6),"0.0000")&"x "&IF(INTERCEPT($B$2:$B$6,$A$2:$A$6)<0,"- ","+ ")&TEXT(ABS(INTERCEPT($B$2:$B$6,$A$2:$A$6)),"0.0000")

For the sample data, the displayed result is y = 1.9200x + 1.0400. The format string “0.0000” controls the number of decimal places shown; change it if you want fewer or more. The displayed precision is a presentation choice, not a change to the underlying regression coefficients. For calculations, refer to the numeric slope and intercept cells rather than trying to extract numbers from the text label.

Use the coefficients to predict a value

Once the coefficients are in cells, you can calculate a predicted y value for a new x value. For example, put the new x value in D2 and place the slope and intercept in E2 and E3. With those cell locations, calculate the prediction in F2 as follows:

=$E$2*D2+$E$3

Using the illustrative data above, a new x value of 6 gives a predicted y of 12.56: 1.92 multiplied by 6, plus 1.04. This is the value on the fitted line, not necessarily an observed data point. Predictions far beyond the range of the original x values are extrapolations, so the equation alone does not guarantee that the same pattern will continue.

If you do not need the coefficients in separate cells, you can calculate a prediction directly from the data. With x in A2:A6, y in B2:B6 and the new x value in D2, use:

=SLOPE($B$2:$B$6,$A$2:$A$6)*D2+INTERCEPT($B$2:$B$6,$A$2:$A$6)

This formula returns 12.56 when D2 is 6 in the sample. The separate-coefficient layout is often easier to audit and reuse; the combined formula is compact when you only need a forecast cell.

Match the worksheet calculation to the chart

In Excel for Microsoft 365 on Windows, select the chart, then choose Chart Design > Add Chart Element > Trendline > More Trendline Options. In the Format Trendline pane, choose Linear and select Display Equation on chart if you want to see the chart’s equation label. Use the same series and observations in the worksheet formulas. If the chart includes multiple series, check that the trendline is attached to the series whose data you are calculating.

Pay special attention to the chart’s horizontal axis. An XY (Scatter) chart uses numeric x values, making it suitable when the actual spacing between x values matters—for example, measurements taken on days 1, 2 and 10. A Line chart uses a category axis, and its trendline generally treats the plotted categories as successive positions. If category labels happen to be numbers, that does not necessarily mean the chart is fitting against those numeric values. A scatter chart is a safer match when you need the regression to use real numeric x values.

Other differences can come from selecting different observations, handling blanks or errors differently, or choosing a different trendline type. Check the chart’s plotted series and the worksheet ranges rather than assuming that matching column headings are enough. For a straightforward comparison, make a scatter chart from the same paired numeric ranges used by SLOPE and INTERCEPT.

Other trendline types need different calculations

The slope-and-intercept method applies to a linear trendline. Excel also offers polynomial, exponential, logarithmic and power trendlines, among others. Their equations have different forms, so a linear formula will not reproduce them. A moving-average trendline is different again: it smooths successive observations and is not a single slope-and-intercept equation.

  • Polynomial: A second-degree trendline has the form y = ax² + bx + c. In Microsoft 365, LINEST can calculate its coefficients when you supply x and x² as separate known-x columns. The coefficient order returned by LINEST is important.
  • Exponential: Excel’s exponential model has the form y = b·emx. It fits a straight line to the natural logarithms of positive y values, so zero or negative y values are not suitable for this transformation.
  • Logarithmic: This model uses the natural logarithm of x and requires positive x values. A linear regression on ln(x) can provide its coefficients.
  • Power: This model has the form y = bxm and uses logarithms of both x and y, so both must be positive for the usual log transformation.

For example, to calculate a quadratic fit with LINEST, arrange x in A2:A6, y in B2:B6, x squared in C2:C6, and x again in D2:D6. Enter the formula in an empty cell such as E2; in Microsoft 365 it spills across E2:G2:

=LINEST($B$2:$B$6,$C$2:$D$6,TRUE,FALSE)

Because the known-x columns are ordered as x² then x, the returned coefficients are in reverse column order: E2 is the coefficient of x, F2 is the coefficient of x², and G2 is the intercept. Write the resulting equation as y = F2x² + E2x + G2. This distinction is easy to miss when building a polynomial equation. If you need a non-linear chart fit, verify its exact model and coefficient order before treating worksheet results as a match.

Common problems and practical checks

  • The equation looks close but predictions differ: The chart label may be rounded. Calculate with the numeric coefficients, not the visible rounded text.
  • The slope seems wrong: Confirm that the first argument is y and the second is x, and that the x and y ranges contain matching rows.
  • The chart and cells disagree: Check whether the chart is a Line chart using category positions, whether the trendline is attached to the intended series, and whether both calculations use the same observations.
  • The intercept is negative: A negative intercept is valid. Use a sign-aware text formula if you want the equation label to show “−” cleanly.
  • The equation label is not a live cell value: Displaying the equation on a chart only adds a chart label. Calculate coefficients in worksheet cells if you need to reference or update them in other formulas.

For changing datasets, use ranges that include the rows you expect to fill, or convert the data to an Excel table and adjust formulas to match the table’s columns. Avoid including headings or unrelated rows in the regression ranges. When inputs change, formulas recalculate automatically, while a manually copied equation in a cell does not.

When to use the chart label instead

If you only need an equation for a report or presentation, displaying it on the chart may be sufficient and quicker than building a worksheet label. It keeps the equation visually associated with the plotted trendline. If you need a prediction, a coefficient for another calculation, or a formula that updates as source data changes, worksheet functions are the better option.

You can use both: keep the chart equation visible for readers and store the unrounded coefficients in cells for calculations. Format those cells to show a useful number of decimals without changing their stored values. This makes it easier to explain the model while preserving the precision used by your workbook.

Frequently Asked Questions

Can I link a cell directly to the equation shown on an Excel chart?
No. The displayed equation is a chart label, not a worksheet value that can be referenced directly. Recalculate the coefficients in cells; for a linear trendline, use SLOPE and INTERCEPT.

How do I get the equation of a linear trendline in Excel?
Use SLOPE(y_range,x_range) for the coefficient of x and INTERCEPT(y_range,x_range) for the constant. The equation is y = slope × x + intercept.

Why does my cell formula not exactly match the chart equation?
The chart label may round its displayed coefficients, or the chart may use a different series, data range, trendline type or x-axis interpretation. Compare full-precision coefficients and confirm that the plotted x values are treated as numeric values.

Can Excel put the equation in a cell automatically?
Not through the chart’s “Display Equation on chart” option. That option displays a label on the chart. Worksheet formulas can calculate and display the equation in cells, and those formulas update when their input data changes.

Can I use SLOPE and INTERCEPT for an exponential trendline?
Not on the original y values if you want Excel’s exponential model. For positive y values, fit a linear relationship to ln(y) and x, then transform the intercept back with the exponential function. The model and data conditions must match the chart.

Related

Try it: the Percentage Formula Generator: percent of, percent change, increase and decrease, with the formula.

More in Charts & pivot tables

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.