5

In Excel, I have an hours log that looks like this:

PersonID   Hours   JobCode
1          7       1
1          6       2
1          8       3
1          10      1
2          5       3
2          3       5
2          12      2
2          4       1

What I would like to do is create a column with a running total, but only within each PersonID so I want to create this:

PersonID   Hours   JobCode    Total
1          7       1          7 
1          6       2          13
1          8       3          21
1          10      1          31
2          5       3          5
2          3       5          8
2          12      2          20
2          4       1          24

Any ideas on how to do that?

Ryan
  • 53
  • 1
  • 1
  • 3

2 Answers2

12

In D2 and fill down:

=SUMIF(A$2:A2,A2,B$2:B2)
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
2

Assuming that your data starts in cell A1, this formula will accumulate the hours until it finds a change in person ID.

=IF(A2=A1,D1+B2,B2)

Put the formula in cell D2, and copy down for each row of your data.

DeanOC
  • 7,142
  • 6
  • 42
  • 56