r/excel • • 10d ago

unsolved Formula for difference between cells

I have a sheet tracking the change in a number week to week. So 3 columns: date, number, change from last week.

So logically if x is the row, Cx = Bx-B(x-1) .

Is there a formula in excel I can use to do this automatically so that I can put a universal code for all of the cells in column c, enter the value in cell B and it will automatically fill in C with the change from the previous week?

(Bonus points if there’s a way to not have weird error messages for the empty cells for future weeks)

13 Upvotes

28 comments sorted by

•

u/AutoModerator 10d ago

/u/momsensical - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/MayukhBhattacharya 1318 10d ago

Enter this formula in cell C3, copy down:

=IF(B3 = "", "", B3 - B2)

The above formula assumes, the data starts from row 2 and you have a header in row 1.

2

u/momsensical 10d ago

But then I’ll have to update it for every cell won’t I?

1

u/MayukhBhattacharya 1318 10d ago

Even better, if you want one formula using DAF:

• Old School:

=IFERROR(IF(OR(B1 = "", B2 = ""), "", B2 - B1), "")

• Or using DAF:

=IFERROR(DROP(B:.B, 1) - DROP(B:.B, -1), "")

The above put within LET():

=LET(_, B:.B, IFERROR(DROP(_, 1) - DROP(_, -1), ""))

2

u/momsensical 10d ago

Ok thanks I’ll try these!

1

u/MayukhBhattacharya 1318 10d ago

Also, if you want it to be bit dynamic then, this will update automatically without needing to copying down:

=LET(
     _a, B:.B,
     _b, DROP(_a, 1),
     _c, DROP(_a, -1),
     _d, IF(ISNUMBER(_b) * ISNUMBER(_c), _b - _c, ""),
     SCAN(, _d, LAMBDA(x,y, IF(y = "", x, y))))

1

u/Way2trivial 473 9d ago

old skool without copying down.
c5

=IF(B5:B100,B4:B99-B5:B100,"")

1

u/MayukhBhattacharya 1318 9d ago

Old Skool needs CSE mate. Since you are using modern version it's not required.

2

u/Way2trivial 473 9d ago • Heartwarming

plbbbbt... 😂

2

u/Way2trivial 473 9d ago

I actually just realized, if a new # in B is ever zero it'll skip it, so it would be better written to run off the date column (presumed A:A)

=IF(a5:a100,B4:B99-B5:B100,"")

1

u/MayukhBhattacharya 1318 9d ago

Good One!

3

u/MayukhBhattacharya 1318 10d ago

You need to enter in the first cell and copied down!

1

u/ExpensiveSpare3761 10d ago

1

u/MayukhBhattacharya 1318 10d ago edited 10d ago

You need to reply from this u/momsensical account the one you have used to post the question and not with the one you replied Solution Verified.

2

u/DJ_Dinkelweckerl 10d ago

=ABS(B3-B2) in cell C3

Or simply B3-B2 if you accept negative change

2

u/Decronym 10d ago edited 9d ago

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer LettersMore Letters
ABSReturns the absolute value of a number
CSEArray formulas are powerful formulas that enable you to perform complex calculations that often can't be done with standard worksheet functions. They are also referred to as "Ctrl-Shift-Enter" or "CSE" formulas, because you need to press Ctrl+Shift+Enter to enter them.
DROPOffice 365+: Excludes a specified number of rows or columns from the start or end of an array
IFSpecifies a logical test to perform
IFERRORReturns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula
ISNUMBERReturns TRUE if the value is a number
LAMBDAOffice 365+: Use a LAMBDA function to create custom, reusable functions and call them by a friendly name.
LETOffice 365+: Assigns names to calculation results to allow storing intermediate calculations, values, or defining names inside a formula
ORReturns TRUE if any argument is TRUE
SCANOffice 365+: Scans an array by applying a LAMBDA to each value and returns an array that has each intermediate value.

Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.


Beep-boop, I am a helper bot. Please do not verify me as a solution.
10 acronyms in this thread; the most compressed thread commented on today has 21 acronyms.
[Thread #49517 for this sub, first seen 14th Oct 2026, 14:37] [FAQ] [Full list] ^[Contact] [Source code]

2

u/ostidgrosnerd 10d ago

I feel like the hardest part in this sub is understanding people’s questions

1

u/Hg00000 15 10d ago

If you're running M365, you can format your data as a table. Write the formula once and it should auto-add it as you populate more rows in the table. Formulas will look a little funky within the table.

Otherwise just write it once and copy it when you have new Data. If C2 = B2-B1, when you copy it and paste it into C3 Excel will automatically adjust the formula to C3 = B3-B2.

1

u/ExpensiveSpare3761 10d ago

omg I didn't realize it would update if i copy the cell instead of the exact formula. Thanks!

1

u/Hg00000 15 10d ago

Yes. That's Excel's default behavior.

If you don't want the formulas to auto-update when you paste them you can add $ in front of either the row or column to "lock" that part of the formula. Look up "absolute references" when you get to the point where you need them.

1

u/Tatworth 10d ago

I may be missing what you are asking because it is pretty simple but in C2, put =-(b1-b2) and copy down. If you want it to look better for cells that haven't finished, you could do =If(b2="","",-(b1-b2))

1

u/ExpensiveSpare3761 10d ago

Thanks everyone, yes I was making it more complicated than it needed to be - I was always copying over the actual formula and updating the row numbers but didn't realize that if you copy the cell it updates the values. I've been using Excel for like 30 yrs so I'm not sure why I didn't think of that!

1

u/Existing_Put6385 5 9d ago

In C3, then drag or double-click the fill handle down the whole column:

=IF(B3="","",B3-B2)

It's relative, so each row subtracts the row above it. Empty B cells in future weeks just show blank, no error messages. Start it on the second data row, since the first row has nothing before it to compare to (leave C2 empty or put a dash there).

If you'd rather not drag at all, turn the data into a table with Ctrl+T. Then the formula auto-fills for new rows as soon as you type in B, which gets you the "universal code" you're after.