How Do You Calculate Slope in Excel

“calculate slope in excel” comes up constantly, so this page leads with the exact answer, and only then explains the detail. Everything works in Excel on Windows and Mac and maps almost one-to-one to Google Sheets. Copy the answer above and get back to work, or read on to turn a one-off fix into something you never have to look up again.

Exact answer

In Excel: use =SLOPE(known_ys, known_xs) and =INTERCEPT(known_ys, known_xs) — together they give the two coefficients of the best-fit straight line, y = slope × x + intercept.

On this page8

Syntax

=SLOPE(known_ys, known_xs) and =INTERCEPT(known_ys, known_xs)

Arguments

Argumentrequired / optionalDescription
known_ysrequiredThe dependent values — the thing being predicted.
known_xsrequiredThe independent values, the same size as known_ys.

Related functions

FORECASTCORRELTREND
Annotated stepsExcel
1

Select a cell for the slope and type =SLOPE(.

2

Select the y values (the outcome) FIRST, then a comma, then the x values.

3

Repeat in a second cell with =INTERCEPT and the same argument order.

4

Combine them as intercept + slope × x to predict any new value.

Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

Need it as an auditable file?

Ships inside the linked template — formula-driven, unlocked, audit-ready.

View template

What this does

SLOPE and INTERCEPT return the two numbers that define the least-squares regression line through a set of points. SLOPE is the rate of change — how much y moves per unit of x — and INTERCEPT is where the line crosses at x = 0. Written out they reproduce exactly the trendline equation a chart displays, which makes them the way to use a fitted line in calculations rather than merely look at one. Watch the argument order: the y values come first, which is the reverse of how most people say "x against y". Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. Treat “calculate slope in excel” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected cells shows up while it is still harmless. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That turns a calculation you can defend to a CFO or an auditor into a method you can reuse, explain, and defend when the workbook leaves your screen.

A worked example

Units produced in B2:B40 and total cost in C2:C40: =SLOPE(C2:C40, B2:B40) returns the variable cost per unit and =INTERCEPT(C2:C40, B2:B40) the fixed cost. Predicting the cost of 250 units is then =INTERCEPT(...) + SLOPE(...)*250, which is what FORECAST.LINEAR does in a single call. SLOPE and INTERCEPT take a chart trendline out of the picture and put it into the model, where it can drive actual calculations. A practical tip before you scale it up: build it once on a small block of test data, confirm the number against the tool on this page, and only then point it at your real sheet. That one habit catches almost every mistake while it is still cheap to fix, long before a wrong figure reaches a report or a colleague.

In Google Sheets

Google Sheets handles this almost identically to Excel. The formula syntax above is the same, and the menu lives under a slightly different label rather than a ribbon tab. Use the platform toggle at the top of the page to switch every keyboard shortcut between Windows and Mac, and expect at most cosmetic differences in naming. Nothing on this page is behind a login or a download: the exact answer is at the top, and the detail below it is there for when you need it. That is the whole promise here — the answer first, and just enough context to make it stick. If you take one thing from this page on “calculate slope in excel”, make it the habit rather than the keystrokes: set the problem up with labelled inputs, reference those cells, and let Excel do the recomputing. Bookmark the page for the syntax, but do the example once in a blank sheet and check it against the tool above — five minutes of hands-on practice fixes the method in memory far better than re-reading, and it surfaces the small snags while they are still harmless. After that the technique is genuinely yours: faster than searching for it again, and reliable enough to drop into work that other people depend on.

Common mistakes

  • Reversing the arguments — y comes first in both functions, and swapping them silently returns a different line.
  • Extrapolating far beyond the observed x range, where a straight line has no support from the data.
  • Fitting a line to plainly curved data; check the scatter plot before trusting either coefficient.

Frequently asked questions

Which argument comes first?

The y values — the thing being predicted. =SLOPE(known_ys, known_xs).

How do I get the trendline equation from a chart into cells?

SLOPE and INTERCEPT return exactly those two coefficients, so you can use the fitted line in formulas instead of reading it off the chart.

How do I predict a value?

=INTERCEPT(ys,xs) + SLOPE(ys,xs)*newX, or the shorter =FORECAST.LINEAR(newX, ys, xs).

Other ways people ask this

This is also commonly searched as “how to calculate slope in excel”, “how to calculate the slope on excel” and “calculate slope in excel”. They describe the identical operation, so you are in the right place no matter how you phrased it.

Why do people search for this in so many different ways?

Because the same task has many names. “how to calculate slope in excel”, “how to calculate the slope on excel”, “calculate slope in excel” all point at the one operation explained on this page, which is why they all lead here.