Reputation: 29
I have an Excel worksheet where I write down all the hours per day I work on my project. During one day I just work some minutes here and there.
In one column of my sheet I would like to have the accumulated / added hours I worked at that specific day.
So once a row with day
, start
, and end
is complete, the referring accumulated hours per day
for this new row should appear.
I would like to have this cell prefilled, so that I do not have to make any manual adjustments of the contents of this cell.
How has a formula in column accumulated hours per day
have to look like to achieve this?
Upvotes: 0
Views: 388
Reputation: 34265
You could also try an array formula version:
=SUBTOTAL(9,OFFSET(C2,0,0,ROW(A2:A9)-1))-IFERROR(SUBTOTAL(9,OFFSET(C2,0,0,MATCH(A2:A9,A2:A9,0)-1)),0)-
(SUBTOTAL(9,OFFSET(B2,0,0,ROW(A2:A9)-1))-IFERROR(SUBTOTAL(9,OFFSET(B2,0,0,MATCH(A2:A9,A2:A9,0)-1)),0))
or more dynamically using Excel 365 Let and Sequence:
=LET(range,A2:INDEX(A:A,COUNTA(A:A)),r,ROWS(range),
SUBTOTAL(9,OFFSET(C2,0,0,SEQUENCE(r)))-IFERROR(SUBTOTAL(9,OFFSET(C2,0,0,MATCH(range,range,0)-1)),0)-
(SUBTOTAL(9,OFFSET(B2,0,0,SEQUENCE(r)))-IFERROR(SUBTOTAL(9,OFFSET(B2,0,0,MATCH(range,range,0)-1)),0)
))
Upvotes: 0
Reputation: 43
I would suggest creating a pivot table and there you can do many things.
Upvotes: 0
Reputation: 117124
You're looking for this:
=IF(A2<>A1,0,D1)+C2-B2
Ideally, I'd suggest avoiding references in the over row by using OFFSET
. Try this instead:
=IF(A2<>OFFSET(A2,-1,0),0,OFFSET(D2,-1,0))+C2-B2
Upvotes: 2