Counting each occurrence of consecutive values in a column

spill-the-beans

Board Regular
Joined
Feb 7, 2013
Messages
52
Hello,

I have a rather large dataset, and apart from the top row (which is a header row), all the data is either a 0 or a 1. Just looking at one column, I could have something like:

[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]index[/TD]
[TD]data[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]

In another sheet, I would like a summary of information in just the data column B. There are two things I need to know:

1. How many series of 1s (so 2 or more 1s one after the other vertically) there were in the entire column. There will never be a 1 by itself with a 0 both above and below it.

2. How long each individual series was - so how many 1s there were in that vertical series.

So for the example above, I would ideally end up with something that looks like:

[TABLE="width: 500"]
<tbody>[TR]
[TD]How many series?[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Length of 1st series[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Length of 2nd series[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Length of 3rd series[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]

If anyone can help me, please let me know! At the moment I am counting by hand!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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