# Getting the slope of the 10 cells above current

I'd like a formula for Google Sheets, but I'm having trouble figuring it out.

Say I'm on B74, I want the equivalent of `=SLOPE(B36:B63,A36:A63)`. However, I want something that will work even when I add a new row under 63. At which point, I want `=SLOPE(B37:B64,A37:A64)`.

I used `=AVERAGE(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),-38,,28))` works perfectly to get the average value within this range, but I can't figure out one for slope.

• This question has been bumped by Community User 8 times. Oct 15, 2023 at 21:55

The answer depends on how your sheet is laid out. You are saying that the formula is in cell `B74`. If there are no more numbers in the sheet between the data table and the formula cell, you can modify the range references so that they include all rows until row `73`, like this:
`=slope(B36:B73, A36:A73)`
Empty rows are ignored by `slope()`.
If the data table is the last thing in columns `A:B`, and you can move the formula cell elsewhere, say column `C`, you can use open-ended references like this:
`=slope(B36:B, A36:A)`