SUM data from a column if value from another column follows a specific value

Peatawn

New Member
Joined
Apr 22, 2013
Messages
37
Hi,

I'm trying devise a formula to sum the data from the "Seconds" column whenever a "1" follows a "4" from the "Mode" column. I don't want to sum where there are "4's" or "1's" following other "1's".

Here's an example (in this case the sum would be 59):
[TABLE="width: 50, align: left"]
<tbody>[TR]
[TD]Seconds[/TD]
[TD]Mode[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]55[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]17
[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]32[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]
























To add to the complexity, the number of rows is variable from file to file.

One of the solutions I have right now is to implement a loop in my VBA to run through all the data record by record. But the point of this thread is to try and find another solution seeing as this has to be summed up in over 40 different daily-generated files that could contain somewhere between 200-300 records each.

Version: Excel 2007

Any ideas would be appreciated.

Thanks,
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
With your data header row in row 1 and the numeric data commencing in row 2

=SUMIFS(A2:A15,B1:B14,4,B2:B15,1)
 
Upvote 0
Brilliant! It's why I didn't think of it before that frustrates me. Guess my head had seen enough of these tables I needed a brilliant mind to help me with it. Thanks a lot! I will be able to adjust this to make it applicable to tables of any row count.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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