Fit a straight line to data and read off its equation. SLOPE gives the rate of change and INTERCEPT the starting value — together, y = slope·x + intercept.
The example
The best-fit line’s equation.
| A | B | |
|---|---|---|
| 1 | Coefficient | Value |
| 2 | Slope | 2.5 |
| 3 | Intercept | 10 |
The formula
The formula:
How it works
How it works:
SLOPE(known_ys, known_xs)is the line’s steepness — how much y changes per unit of x.INTERCEPT(known_ys, known_xs)is where the line crosses the y-axis (y when x = 0).- Predict with
=slope*x + intercept, or useFORECAST.LINEAR(x, ys, xs)in one step. - Note the argument order: ys first, xs second — easy to reverse by mistake.
Check the fit: pair these with RSQ(ys, xs) — the R-squared — to see how well the line explains the data. A slope is only meaningful if the relationship is reasonably linear.
Try it: interactive demo
Pairs “x,y”.
Variations
Predict y
One step:
R-squared
Fit quality:
Full stats (LINEST)
Coefficients + errors:
Pitfalls & errors
ys first, xs second. Reversing the arguments flips the relationship.
Linearity assumed. A slope on curved data is misleading; check the R-squared and a scatter plot.
Equal-length ranges. xs and ys must have the same count.
Practice workbook
Frequently asked questions
How do I find the slope and intercept of data in Excel?
How do I predict a value from the line?
How do I check if the line fits well?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class