View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default CountIf / SumProduct in VB

On Jun 21, 4:59 am, "Vacuum Sealed" wrote:
What would be the best approach for the following scenario:

[....]
Sub TrafficFlow()
Dim myRng As Range
Set myRng = [F4:F300]
If myRng.Value = #12:00:00 AM# And _
myRng.Value < #1:00:00 AM# _
Then Range("M5") = Count(myRng)
End If
If myRng.Value = #1:00:00 AM# And _
myRng.Value < #2:00:00 AM# _
Then Range("M6") = Count(myRng)
End If


Sub TrafficFlow()
Dim myRng As Range, c as Range
Set myRng = Range("F4:F300")
For Each c in myRng
Range("M" & 5+Hour(c)) = myRng.Count
Next

In a later posting, you used cells(6,i).Count. That makes little
sense since the Count is always 1 in that context.