May be you can just Offset the Range by 1 row as shown below.
You will Not be able to use Entire Column references using this method, but you can make the range very large, more than you think you'll ever need, like B2:B100000 or whatever you want:
Book3.xlsx |
---|
|
---|
| A | B | C |
---|
1 | 44607.94 | OFF | |
---|
2 | 44608 | ON | 0.014594 |
---|
3 | 44608.01 | OFF | 0.014594 |
---|
4 | 44608.01 | ON | |
---|
5 | 44608.02 | OFF | |
---|
6 | 44608.02 | ON | |
---|
7 | 44608.02 | OFF | |
---|
|
---|
I almost had it
=IF(B1="off",SUMIF(B:B,"On",A:A)-SUMIF(B:B,"Off",A:A),SUMIF(B:B,"Off",A:A)-SUMIF(B:B,"On",A:A))
however the trick is that the data extract comes form two dates so I need to account for that, however the first field and last field in A does not finish on the exact start and end dates
so I needed to find the last numerical value in the date column A
={INDEX(A:A,MATCH(9.99999999999999E+307,A:A))}
this is now the helper cell J1
and the start date - cell A1
and the difference between the two extract dates K1 and L1
and the difference between the end date L1 and the helper cell J1 the last numerical output in column A
=IF(B1="off",(L1-K1)-(L1-J1)-(A1-K1)-(SUMIF(B:B,"On",A:A)-SUMIF(B:B,"Off",A:A)),SUMIF(B:B,"Off",A:A)-SUMIF(B:B,"On",A:A))
however the spanner in the works is if the last cell in B is also "OFF" as well as B1 and vice versa for B1 and last value also being "ON"
I think I now need a formula to find the last ON and the last OFF and return the row numbers
then use A1:INDEX(A:A,"last row number") to fix this
I would also need a formula to return the corresponding date/time of the last "On" and "OFF"
then I can construct some logic for the different scenarios with some careful thought as to not add error from the first and the final sampled data and the end date.