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

I would you count zero values between real values inclusive?
Hopefully in VBA
Such as:

A B C
1 2
2 0
3 0
4 1 count 4
5 1
6 0
7 1 count 3
8 1
9 1 count 2
10 8
11 0
12 2 count 3

With Thanks
Steve


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Count between Values

Sub Test()
Dim iLastRow As Long
Dim i As Long
Dim iStart As Long

iLastRow = Cells(Rows.Count, "B").End(xlUp).Row
iStart = 1
For i = 2 To iLastRow
If Cells(i, "B").Value < 0 Then
Cells(i, "C").Value = i - iStart + 1
iStart = i + 1
i = i + 1
End If
Next i

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"smandula" wrote in message
...
I would you count zero values between real values inclusive?
Hopefully in VBA
Such as:

A B C
1 2
2 0
3 0
4 1 count 4
5 1
6 0
7 1 count 3
8 1
9 1 count 2
10 8
11 0
12 2 count 3

With Thanks
Steve




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Count between Values

Thanks a lot!!
Works perfectly

Thanks Again
Steve



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Count between Values

R = 1

Do While Cells(R, 1) < ""

ZeroCnt = 0
Flag = 0

Do While Cells(R, 2) = 0
ZeroCnt = ZeroCnt + 1
R = R + 1
Flag = 1
Loop

If Flag = 0 Then R = R + 1
If Flag = 1 Then Cells(R, 3) = "count " & ZeroCnt + 2

Loop

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 Intervals of 2 Consecutive Values in same Row and Return Count across Row Sam via OfficeKB.com Excel Worksheet Functions 6 November 29th 05 03:27 PM
Count Intervals of 2 Numeric values in same Row and Return Count across Row Sam via OfficeKB.com Excel Worksheet Functions 12 September 24th 05 10:58 PM
Count unique values and create list based on these values vipa2000 Excel Worksheet Functions 7 August 5th 05 01:17 AM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM
Using the COUNT funciton to count cells with values wjsubs[_5_] Excel Programming 4 July 9th 04 05:00 PM


All times are GMT +1. The time now is 09:49 PM.

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

About Us

"It's about Microsoft Excel"