Get Cell Difference in Array SCAN/LAMBDA

MrRajKumar

Active Member
Joined
Jan 29, 2008
Messages
280
Office Version
  1. 365
Platform
  1. Windows
Hi,

The following are the data in A1:A5


2​
3​
6​
8​
20​

In B1:B5, I would like to get their difference in spill format. If we do this manually, it will be;

B1: =A1
B2: =A2-A1
B3: =A3-A2
B4: =A4-A3
B5: =A5-A4

So the final result should be

2
1
3
2
12

I tried this formula, but doesn't work.

=SCAN(0,A1:A5,LAMBDA(x,y,y-x))
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
SCAN acts as an accumulator. What it's doing is:
3-2 = 1
6 - 1 = 5
8 -5 = 3 and so on ...

It subtracts from the prior result not the prior cell. Try this.

Book2
ABC
1211
2333
3622
481212
520
Sheet2
Cell Formulas
RangeFormula
B1:B4B1=MAKEARRAY(ROWS(A1:A5)-1,1,LAMBDA(r,c, INDEX(A1:A5,r+1)-INDEX(A1:A5,r)))
C1:C4C1=A2:A5-A1:A4
Dynamic array formulas.
 
Upvote 0
Solution
Thank you. I used the 2nd method with the help of TAKE/DROP formulas.
 
Upvote 0

Forum statistics

Threads
1,215,205
Messages
6,123,632
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top