CountIf / SumProduct in VB
On Jun 21, 10:24*am, joeu2004 wrote:
On Jun 21, 7:48*am, "Vacuum Sealed" wrote:
Sorry Joe
That halted on:
* * Range("M" & 5+Hour(c)) = Range("M" & 5+Hour(c)) + 1
Works fine for me. *I don't know how much spoon-feeding you need.
Copy and paste the following:
Sub TrafficFlow()
Dim myRng As Range, c As Range
Set myRng = Range("F4:F300")
For Each c In myRng
* *Range("M" & 5 + Hour(c)) = Range("M" & 5 + Hour(c)) + 1
Next
End Sub
Now, you never explained what you want the code to do. *Something
like: *"F4:F300 contains the times of individual observations. *In
M5:M28, I want to count the number of observations in each hour of the
day".
That is what I assume by the code above. *There are better was to
implement it. *I tried to stray as little from your original
implementation as possible initially.
If you want to avoid VBA altogether, put the following formula into M5
and copy down through M28:
=SUMPRODUCT(--(HOUR($F$4:$F$300)=ROWS($M$5:M5)-1))
Be sure to copy-and-paste the formula.
|