counting strings of numbers

sjournot

New Member
Joined
Mar 24, 2009
Messages
3
I am working with a large set of data and I have something like whats shown below. I only want to count the 1s that are in strings, not the single 1 in red
Is there any way to do that? Not all the strings of 1s are the same size.

0
0
1
1
0
1
0
1
1
1
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I am working with a large set of data and I have something like whats shown below. I only want to count the 1s that are in strings, not the single 1 in red
Is there any way to do that? Not all the strings of 1s are the same size.

0
0
1
1
0
1
0
1
1
1

With the data in A1:A10, control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF(A1:A10=1,ROW(A1:A10)),IF(A1:A10<>1,ROW(A1:A10)))>1,1))
 
Upvote 0
Sorry, I think I mis-spoke. I need to not only count the strings of ones but I need the ones in the strings to be summed up. So that for this example I would get 5 as an answer.
sorry for the confusion.

but thanks for the quick reply!
 
Upvote 0
Not as elegant as I was striving for...but, here's what I came up with

ARRAY FORMULA, committed with CTRL+SHIFT+ENTER
(instead of just ENTER)
Code:
=SUM(FREQUENCY(IF(A1:A10=1,ROW(A1:A10)),IF(A1:A10<>1,ROW(A1:A10)))-
(FREQUENCY(IF(A1:A10=1,ROW(A1:A10)),IF(A1:A10<>1,ROW(A1:A10)))=1))
Does that help?
 
Upvote 0
=SUM(IF(SEARCH("1",A1:A4,1)>0,1,0))-SUM(IF(ISNUMBER(A1:A4),1,0))

complete with Ctrl-Shift-Enter

replace with your range
 
Upvote 0
Sorry, I think I mis-spoke. I need to not only count the strings of ones but I need the ones in the strings to be summed up. So that for this example I would get 5 as an answer.
sorry for the confusion.

but thanks for the quick reply!

If you have the free morefunc.xll add-in installed:

Control+shift+enter, not just enter...

=SUM(IF(SETV(FREQUENCY(IF(A1:A10=1,ROW(A1:A10)),IF(A1:A10<>1,ROW(A1:A10))))>1,GETV()))

which would be a tad faster.

Otherwise, see other replies.
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,643
Members
449,093
Latest member
Ahmad123098

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