Excel Trendline Equation in a Cell: How to Calculate It

Charts & pivot tables · Updated November 21, 2026

Yes. For a linear trendline, calculate its slope and intercept in worksheet cells, then use those values to predict results; Excel does not automatically link a chart’s displayed trendline equation to a cell. With x-values in A2:A6 and matching y-values in B2:B6, enter =SLOPE(B2:B6,A2:A6) in one cell and =INTERCEPT(B2:B6,A2:A6) in another.

What a chart trendline equation represents

A trendline is a model fitted to data points in a chart. For a linear trendline, Excel estimates a slope and an intercept: the slope describes how much the predicted y-value changes for a one-unit change in x, while the intercept is the model’s predicted y-value when x is zero. Once those values are in cells, you can calculate predictions, compare scenarios, and reuse the model without reading an equation off a chart.

The equation shown on a chart is a label, not a worksheet formula or a reference to a cell. Turning on the equation display does not create values that other formulas can refer to. Instead, calculate the model parameters from the same x- and y-data that the chart uses. This is usually more dependable than copying rounded coefficients from a chart label.

For a concrete example, suppose A2:A6 contains 1, 2, 3, 4, 5 and B2:B6 contains 3, 5, 7, 9, 11. The data follow a linear pattern with slope 2 and intercept 1. If the slope is in D2 and the intercept is in D3, the predicted y-value for an x-value in A2 is calculated with =$D$2*A2+$D$3. The formula returns 3 for x = 1; for a new x-value of 6, it returns 13.

Calculate a linear trendline in worksheet cells

Place x-values in one column and their corresponding y-values in another. Each x-value must stay paired with the y-value from the same observation; sorting or deleting only one column can silently produce the wrong fit. The ranges should normally contain numeric observations, not headings. In the example above, enter the slope formula in D2 and the intercept formula in D3. Those functions recalculate when the source data change.

With x-values in A2:A6 and corresponding y-values in B2:B6, enter =SLOPE(B2:B6,A2:A6) in D2 to return the slope. With the same layout, enter =INTERCEPT(B2:B6,A2:A6) in D3 to return the intercept. The argument order matters: both functions take the known y-values first and the known x-values second.

To calculate a fitted value for every observation, put the x-value in A2 and the slope and intercept in D2 and D3. Enter =$D$2*A2+$D$3 in a result column and fill it down. The dollar signs keep the parameter references fixed while the row reference changes. To predict for a separate input, such as a new x-value in F2, use =$D$2*F2+$D$3 in the prediction cell.

Another option is LINEST. With y-values in B2:B6 and x-values in A2:A6, enter =LINEST(B2:B6,A2:A6,TRUE,FALSE) in a cell. In current Microsoft 365 Excel, the result spills horizontally into two cells: slope first, then intercept. SLOPE and INTERCEPT are often easier to read and maintain when you want the parameters in separately labelled cells; LINEST is useful when you want a regression function that can also return additional statistics.

Show the equation on a chart, then verify it

In Excel for Microsoft 365 on Windows, select the chart, then choose Chart Design > Add Chart Element > Trendline and select the appropriate type. For more settings, choose Chart Design > Add Chart Element > Trendline > More Trendline Options. In the Format Trendline pane, select Display Equation on chart. The exact menu presentation can vary with window size, but the chart-element commands are on the Chart Design tab when a chart is selected.

A scatter chart is generally the right choice when both variables are numeric and x-values should be treated as measured distances. To make one, select the two data columns and choose Insert > Insert Scatter (X, Y) or Bubble Chart. A Line chart often treats its horizontal positions as categories spaced evenly apart, even if the labels look numeric. If x-values are dates, irregular measurements, or quantities, check that the chart type represents them the way your analysis intends.

For a fair comparison, use the same observations and the same trendline type in the chart and in the worksheet calculations. The chart label may round its displayed coefficients, so a prediction reconstructed from those visible numbers can differ slightly from a cell calculation using full precision. You can change the number format of the equation label in the Format Trendline Label pane, but that changes its display rather than the underlying fit.

Choose the right method for other trendline types

SLOPE and INTERCEPT reproduce a linear model. Excel also offers exponential, logarithmic, power, polynomial, and moving-average trendlines. These models do not all use the same calculation, so applying the linear formulas to every chart trendline will not reproduce the chart’s equation.

  • Exponential: This model is appropriate when change is more naturally described as a constant percentage than a constant amount, and the y-values must be positive for the logarithmic transformation. Create a helper column C with x-values in A2:A6 and positive y-values in B2:B6. In C2 enter =LN(B2) and fill down. With transformed values in C2:C6 and x-values in A2:A6, calculate the transformed slope in D2 with =SLOPE(C2:C6,A2:A6) and the transformed intercept in D3 with =INTERCEPT(C2:C6,A2:A6). For a new x-value in F2, the corresponding prediction is =EXP($D$3+$D$2*F2).
  • Logarithmic: This model uses the natural logarithm of x, so x-values must be greater than zero. With x-values in A2:A6 and y-values in B2:B6, enter =LN(A2) in C2 and fill down. With the transformed x-values in C2:C6 and y-values in B2:B6, calculate the slope with =SLOPE(B2:B6,C2:C6) and the intercept with =INTERCEPT(B2:B6,C2:C6). For a new positive x-value in F2, use =$D$2*LN(F2)+$D$3 if those parameters are stored in D2 and D3, respectively.
  • Power: This model requires positive x- and y-values. Transform each variable using natural logarithms, then fit a linear trendline between the transformed columns. With x in A2:A6 and y in B2:B6, enter =LN(A2) in C2 and =LN(B2) in D2, and fill both formulas down. Fit slope and intercept using C2:C6 as known x-values and D2:D6 as known y-values. Convert the transformed intercept back with EXP when calculating a prediction; the transformed slope is the exponent on x.
  • Polynomial: A polynomial trendline adds powers of x, allowing curvature. LINEST can estimate its coefficients if you build helper columns for x, x squared, and any higher powers needed. For a quadratic fit, put x in A2:A6, x squared in B2:B6, and y in C2:C6. With that layout, enter =LINEST(C2:C6,A2:B6,TRUE,FALSE) in a cell. The results spill across three cells in reverse predictor order: coefficient for x squared, coefficient for x, then the intercept. A polynomial fit can match a curved pattern, but adding degrees can make it follow noise rather than a useful trend.
  • Moving average: This is a smoothing method, not a single equation with slope and intercept. Excel averages a specified number of neighboring observations to reduce short-term fluctuations. Use it when the goal is to make a series easier to see, rather than to calculate one fixed equation for predicting y from x.

How to check that the cell result is useful

Matching the chart’s equation is not the same as proving the model is a good description of the data. Inspect the plotted points, the residuals (observed values minus fitted values), and whether the model makes sense for the question. A high R-squared value can summarize how closely a fitted model tracks the data in some settings, but it does not establish causation or guarantee accurate future predictions.

For a linear fit, with y-values in B2:B6 and x-values in A2:A6, calculate R-squared with =RSQ(B2:B6,A2:A6). The function returns a value from 0 to 1 for a standard linear relationship; a value near 1 means the fitted line accounts for a large share of the observed variation in this dataset. It does not tell you whether the line is suitable outside the observed x-range. Extrapolating far beyond the data can produce implausible results, particularly for non-linear models.

Also confirm that blank cells, text, outliers, and hidden or filtered rows are being handled as intended. The chart may plot only selected series or may use different ranges from the formulas. Click the chart and inspect Select Data if the plotted points and cell calculations appear inconsistent. If the data contain multiple series, calculate the parameters separately for each series rather than combining unrelated observations.

Common problems and practical fixes

  • The cell result differs from the chart label: Check whether the chart label rounds coefficients, whether the ranges match, and whether the chart uses the same trendline type. Use calculated cell coefficients for predictions rather than manually transcribing a rounded label.
  • The prediction changes unexpectedly when filled down: Lock parameter cells with dollar signs, as in =$D$2*A2+$D$3. Keep the observation reference relative so it advances by row.
  • Excel returns an error or an implausible fit: Check for mismatched range lengths, nonnumeric entries, and invalid inputs for transformations. LN requires a positive number; a logarithmic trendline cannot use zero or negative x-values, and exponential or power transformations cannot take the logarithm of nonpositive y-values.
  • The trendline does not match the point pattern: Confirm the chart’s x-values are numeric and that you selected the intended series. A Line chart’s category axis can be mistaken for a numeric x-axis. Consider whether a different model is justified, but avoid choosing a more complex curve only because it makes the historical chart look closer.

On Mac, the same worksheet functions and chart trendline options are available in current Excel, although ribbon placement and pane appearance can differ by release. Excel for the web supports ordinary worksheet formulas and many chart operations, but some chart-formatting controls may be more limited than the Windows desktop app. If a command is not visible, open the chart-formatting options or use the desktop app for the full set of chart controls.

Frequently Asked Questions

Can Excel put a chart trendline equation directly in a cell?
No built-in chart option links the displayed equation label to a worksheet cell. Calculate the coefficients with functions such as SLOPE and INTERCEPT for a linear trendline, or use LINEST and appropriate transformations for other models.

How do I use a trendline equation to predict a value?
Store the model parameters in cells and refer to them in a formula using the new x-value. For a linear model, multiply the slope by the new x-value and add the intercept. Lock the parameter references with dollar signs if you plan to fill the prediction formula down.

Why does the equation in my chart look different from my formula result?
The chart label may round the coefficients, or the chart and formula may use different data ranges, series, or trendline types. Compare the underlying data and use full-precision worksheet coefficients for calculations.

Can I use SLOPE and INTERCEPT for a polynomial trendline?
Not by themselves. They fit a straight line with one x-variable. For a polynomial, create helper columns for the required powers of x and use LINEST with those columns as predictors.

Does R-squared tell me whether a trendline is reliable?
It describes fit for the data and model used, but it is not a guarantee of predictive accuracy. Check residual patterns, sample size, unusual observations, and whether predictions stay within a reasonable range of the observed data.

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.