Spill Array Formula to Values between Cells on Separate Rows

ScottTemple

Board Regular
Joined
Dec 28, 2023
Messages
103
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a spill array that encompasses columns A - AD with the following formula: =CHOOSECOLS(FILTER(Table9,Table9[Date]<>""),1,2,3...

I would like to calculate the difference between two times that are located on separate rows from each other (see below). The formula I would use in a non spill array is =IF(N3>=O2,N3-O2,N3+1-2)*1440, but that will not work in this instance. Any assistance would be greatly appreciated.

1707244581546.png
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Ah, the day rollover... Try this:

Excel Formula:
=LET(a,CHOOSECOLS(A2#,14),b,CHOOSECOLS(A2#,15),c,DROP(VSTACK("a",b),-1),d,IF(c="a","",IF(a-c>0,a-c,1+a-c)),IFERROR(d*1440,""))
 
Upvote 1
This aught to move it up.
Excel Formula:
=LET(a,CHOOSECOLS(A2#,14),b,CHOOSECOLS(A2#,15),c,DROP(VSTACK("a",b),-1),d,IF(c="a","",IF(a-c>0,a-c,1+a-c)),DROP(IFERROR(d*1440,""),1))

The only change is at the end - the DROP around the IFERROR.
 
Upvote 1
There is always going to be one less row in this calculation, because it's basically differentiating. What would you want in the last row, when it's looking to the next row - but that row has no data.

But you can append a blank or a zero if you like:

=LET(a,CHOOSECOLS(A2#,14),b,CHOOSECOLS(A2#,15),c,DROP(VSTACK("a",b),-1),d,IF(c="a","",IF(a-c>0,a-c,1+a-c)),VSTACK(DROP(IFERROR(d*1440,""),1),""))
=LET(a,CHOOSECOLS(A2#,14),b,CHOOSECOLS(A2#,15),c,DROP(VSTACK("a",b),-1),d,IF(c="a","",IF(a-c>0,a-c,1+a-c)),VSTACK(DROP(IFERROR(d*1440,""),1),0))
 
Upvote 1
Solution
I do something like this - I'll roll one column down one row and put some junk in the front. I don't know if this will be useful for you.

MrExcelPlayground20.xlsx
ABCDEF
1StartFinishStartFinishLag
29:30 PM1:00 AM9:30:00 PM1:00:00 AM 
31:15 AM4:10 AM1:15:00 AM4:10:00 AM15
44:45 AM6:00 AM4:45:00 AM6:00:00 AM35
Sheet28
Cell Formulas
RangeFormula
D2:E4D2=CHOOSECOLS(A2:B4,1,2)
F2:F4F2=LET(a,CHOOSECOLS(D2#,1),b,CHOOSECOLS(D2#,2),c,DROP(VSTACK("a",b),-1),d,IF(c="a","",a-c),IFERROR(d*1440,""))
Dynamic array formulas.
 
Upvote 0
Hey James,

I was out of the office for a couple of week and didn't get a chance to reply back to you until today.

The formula for D2 returns a #SPILL! error; here's an example of my formula: =CHOOSECOLS(N:O,1,2).
 
Upvote 0
N:O is taking the whole columns. When you try to put that starting in row 2, it all just can't fit. If you can make the range smaller, or move the formula up to row 1.
 
Upvote 0
Never mind, I see what you're doing here, but I'm a bit confused on the code. A/B are N/O in my sheet and D2/E2/F2 are BE/BF/BG. How does that translate in the formula you provided for F2?

1708458121697.png
 
Upvote 0
What I was doing in D and E, was to simplify what you had with "=CHOOSECOLS(FILTER(Table9,Table9[Date]<>""),1,2,3.." Basically just a clean array of start and finish values. Then my F column is where I sort that into the Lags between the current rows 'end' and the next rows 'begin'.
 
Upvote 0
Sorry, bit confused by what you mean. Are you suggesting to create a second CHOOSECOLS spill array to include just the Start and FInish times and then use the formula in F2 to create lag times?
 
Upvote 0

Forum statistics

Threads
1,215,632
Messages
6,125,909
Members
449,274
Latest member
mrcsbenson

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