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!


UserClosed ClientIDprocessIDRunning Total
User10875305386961
User101019388386962
User11490512886962
User101019388386962
User11673881786962
User111019388386961
User101019388386961
User101006679386962
User111006679386961
User111019388386960

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
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,215,701
Messages
6,126,289
Members
449,308
Latest member
VerifiedBleachersAttendee

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