Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default count problem


i have numbers 1 and 0 in column a, i would need to know how many 0 are
between ones. how could i find it out? this 1 and o sequence is very
long
A B
1 1
2 0
3 1 1
4 0
5 0
6 1 2
7 0
8 0
9 0
10 1 3
Thanks


--
muumigirl
------------------------------------------------------------------------
muumigirl's Profile: http://www.excelforum.com/member.php...o&userid=30674
View this thread: http://www.excelforum.com/showthread...hreadid=503314

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default count problem

You could try something like this...

Sub CountZeros()

Dim intStartCounter as integer
Dim intCounter as integer

intstartcounter = 1
intCounter = 1

do while len(range("B" & intCounter).text) < 0

do while range("B" & intCounter).text < 1

intcounter = intcounter + 1

loop

range("C" & intcounter).value = intcounter - (intstartCounter + 1)

intStartCounter = intcounter

Loop

I haven't tested this and wrote it directly here, so please check syntax.
Also, this assumes that the data is in column B and starts in row 1. If this
is wrong, you'll need to alter this in the code above.

HTH.

"muumigirl" wrote:


i have numbers 1 and 0 in column a, i would need to know how many 0 are
between ones. how could i find it out? this 1 and o sequence is very
long
A B
1 1
2 0
3 1 1
4 0
5 0
6 1 2
7 0
8 0
9 0
10 1 3
Thanks


--
muumigirl
------------------------------------------------------------------------
muumigirl's Profile: http://www.excelforum.com/member.php...o&userid=30674
View this thread: http://www.excelforum.com/showthread...hreadid=503314


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default count problem

Put this formula in B2

=IF(A2=0,"",COUNTIF(INDIRECT("A"&MAX(IF($A$1:A1=1, ROW($A$1:A1)))&":A"&ROW()-
1),0))

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter. Then copy B2 down

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"muumigirl" wrote
in message ...

i have numbers 1 and 0 in column a, i would need to know how many 0 are
between ones. how could i find it out? this 1 and o sequence is very
long
A B
1 1
2 0
3 1 1
4 0
5 0
6 1 2
7 0
8 0
9 0
10 1 3
Thanks


--
muumigirl
------------------------------------------------------------------------
muumigirl's Profile:

http://www.excelforum.com/member.php...o&userid=30674
View this thread: http://www.excelforum.com/showthread...hreadid=503314



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count Problem Suleman[_2_] Excel Discussion (Misc queries) 0 June 16th 08 04:20 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
COUNT IF (AND / OR) SUM IF PROBLEM Anthony Mann Excel Worksheet Functions 2 April 17th 07 08:10 PM
count problem vipa2000 Excel Worksheet Functions 6 July 28th 05 09:28 AM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"