Conditional COUNTIF using logicals
Conditional COUNTIF using logicals
(OP)
I have an array of 8760 hourly data kW readings for a year (24 by 365). I want to count the number of hours >= 15000 this works but then using and the AND logical it does not work. Here is formula that does not work =countif(D4:AA368), (AND>14900, (D4:AA368)<=15000)) it gives me zero.
Can someone please help me out with this feature?
Can someone please help me out with this feature?
RE: Conditional COUNTIF using logicals
Assume D1 contains the minimum value (14900), and D2 contains the max value (15000).
=if(AND(D4>$D$1,D4<=$D$2),1,0)
Then just copy the formula, and sum the results?
RE: Conditional COUNTIF using logicals
You could always use a Macro:
Sub Macro1()
Dim c As Range
Dim x As Range
Set x = Sheet1.Range("D4:AA368")
For Each c In x
If c.Value <= 15000 And c.Value > 14900 Then
q = q + 1
End If
Next c
Sheet1.Range("a1").Value = q
End Sub
Good Luck
johnwm
________________________________________________________
To get the best from these forums read FAQ731-376 before posting
RE: Conditional COUNTIF using logicals
SUM(IF(C3:C8762>15000,1,0))
Array function? Use <crtl>-<shift>-<enter> rather than just <enter> when you have finished typing the formula. The formula will then appear as if you typed it with {braces} around it.
For greater flexibility, you can put your threshold value of 15000 into a cell and reference that cell in the IF function.
HTH
RE: Conditional COUNTIF using logicals
RE: Conditional COUNTIF using logicals
TTFN
RE: Conditional COUNTIF using logicals