# excel sequence count

hi everyone,

i want to count the number of sequences of 1's in consecutive cells..eg 11100010011001, there are 4 sequences of ones here..can someone tell me what formula to use to do this in excel??

thanks
oggiemc
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Assuming your data is in A1:A14 you can use this formula
=SUMPRODUCT((A1:A14=1)*(OFFSET(A1:A14,1,0)<>1))
regards, barry
0
Commented:
If your range is a horizontal range rather than a vertical one then the OFFSET part changes a little, e.g. if data range is A1:N1 then use
=SUMPRODUCT((A1:N1=1)*(OFFSET(A1:N1,0,1)<>1))
regards, barry
0
Author Commented:
Hi Barry,
My data is vertical..
that formula is just giving me back 0. Any ideas??

Runs      Runs of 1
0      0
1
1
0
1
0
0
0
0
0
1
0
1

0
Commented:
****No points****

If you select your column of 1s and 0s and go Data>TextToColumns>Finish does the formula now return a value?

If so it would indicate that you had text 1s/os rather than numeric 1s/0s

Richard
0
Commented:
if Richard is right then you could also just change the 1s in the formula to "1"s, i.e.

=SUMPRODUCT((A1:A14="1")*(OFFSET(A1:A14,1,0)<>"1"))

Regards, barry
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
thanks guys, it was text values..will split points :)
0
Commented:
Please don't split the points - your solution was all Barrie (and was a very clever solution I thought - much better than the one I came up with which was far too complicated to post).
0
Author Commented:
ok, will give to barry..thanks
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.