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
oggiemcAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

barry houdiniCommented:
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
barry houdiniCommented:
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
oggiemcAuthor 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
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

RichardSchollarCommented:
****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
barry houdiniCommented:
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

Your issues matter to us.

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

Start your 7-day free trial
oggiemcAuthor Commented:
thanks guys, it was text values..will split points :)
0
RichardSchollarCommented:
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
oggiemcAuthor 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.