Count between Hi and Low
How about a variation on Jonathan's solution.
In 'D' D2 = if (C2<"",D1+1,1)
This looks at column 'C' and 'counts' till it finds another entry in 'C'
In 'E' E2 if (C3 < "" ,D2,"")
This looks at column C and displays the 'count' just before there is an
entry in 'C'
This any use?
Chris
"smandula" wrote in message
...
Thanks very much for your reply. The VBA works perfect on total.
Sorry to say I need the number or count between grouping. For instance
Low+blank=2 next item Hi+blank+blank=3 next item
Low+blank+blank+blank=4 next item Hi =1 next item Hi+blank+lank=3
Could this grouping be possible?
Thank Again
"Charles Harmon" wrote in message
...
Hi,
You can try this:
Sub HiLowCnt()
Dim cell As Range, rng As Range
Dim prev
Dim hicnt As Integer, locnt As Integer
Set rng = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
For Each cell In rng
If cell.Offset(0, 1) = "Low" Then
locnt = locnt + 1
prev = "Low"
ElseIf cell.Offset(0, 1) = "" And prev = "Low" Then
locnt = locnt + 1
End If
If cell.Offset(0, 1) = "Hi" Then
hicnt = hicnt + 1
prev = "Hi"
ElseIf cell.Offset(0, 1) = "" And prev = "Hi" Then
hicnt = hicnt + 1
End If
Next cell
Range("D1").Value = "Low Cnt " & locnt
Range("D2").Value = "Hi Cnt " & hicnt
End Sub
Charles
"smandula" wrote in message
...
How do I count the rows between Hi and Low stock values?
And Low to Hi.
Col B C
58.0 Low
59.7
63.0 Hi
58.5
60.4
62.2 Low
65.4
63.0
64.3
66.4 Hi
70.0 Hi
66.4
64.0
62.0 Low
Put result in Col D
With Thanks
|