VBA or Formula for Running Total

stwp86

New Member
Joined
Jun 28, 2012
Messages
19
Hey Everyone . . .

Looking for some assistance on a formula or VBA. I have the below dataset and I am trying to automate the calculation of the running total. Basically, I need it to say, if the user stays the same, the processID stays the same, the client id is new, and the closed column is 0 the increment my running total. But if the same client comes up (row 4 for example) I don't want to increment my running total. Also, if closed is equal to 1 I need to decrease the running total appropriately, so for the first 3 rows I see the total go from 0 to 1 to 2 to 3, but on the third row they closed, so I need to the running total at 2. Thoughts?

thanks!


[TABLE="class: grid, width: 357, align: left"]
<colgroup><col><col><col><col><col></colgroup><tbody>[TR]
[TD]User[/TD]
[TD]Closed [/TD]
[TD]ClientID[/TD]
[TD]processID[/TD]
[TD]Running Total[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]0[/TD]
[TD]8753053[/TD]
[TD]8696[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]0[/TD]
[TD]10193883[/TD]
[TD]8696[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]1[/TD]
[TD]4905128[/TD]
[TD]8696[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]0[/TD]
[TD]10193883[/TD]
[TD]8696[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]1[/TD]
[TD]6738817[/TD]
[TD]8696[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]1[/TD]
[TD]10193883[/TD]
[TD]8696[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]0[/TD]
[TD]10193883[/TD]
[TD]8696[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]0[/TD]
[TD]10066793[/TD]
[TD]8696[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]1[/TD]
[TD]10066793[/TD]
[TD]8696[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]User1[/TD]
[TD]1[/TD]
[TD]10193883[/TD]
[TD]8696[/TD]
[TD]0[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Why doesn't the running total increase from 2 to 3 on row 4? User is same, closed is 0, client is different, and processID is same.

Based on your explanation, the following equation works:
=IFERROR(IF(AND(A2=A1,D2=D1,C2<>C1),E1+1,E1)+IF(B2=1,-1,0),1)
Just paste it in E2 and autofill it down.
 
Upvote 0
<br />
Book1
ABCDE
1UserClosedClientIDprocessIDRunning Total
2User10875305386961
3User101019388386962
4User11490512886962
5User101019388386962
6User11673881786962
7User111019388386961
8User101019388386961
9User101006679386962
10User111006679386961
11User111019388386960
Sheet1
Cell Formulas
RangeFormula
E3=AND(A3=A2,COUNTIF($C$2:C3,C3)=1,D3=D2)-B3+E2


Put a 1 for the first running total value in E2.
Copy the E3 formula down column E for the other running totals.
 
Upvote 0
ClientID is the same as a previous one, so it is not net new.

Why doesn't the running total increase from 2 to 3 on row 4? User is same, closed is 0, client is different, and processID is same.

Based on your explanation, the following equation works:
=IFERROR(IF(AND(A2=A1,D2=D1,C2<>C1),E1+1,E1)+IF(B2=1,-1,0),1)
Just paste it in E2 and autofill it down.
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,089
Members
452,542
Latest member
Bricklin

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