Function CountBetw(iRange As Range, lowNum, hiNum, Optional inclLow =
_ True, Optional inclHi = True)
If inclLow = True And inclHi = True Then
CountBetw = Application.CountIf(iRange, "=" & lowNum) - _
Application.CountIf(iRange, "" & hiNum)
ElseIf inclLow = False And inclHi = False Then
CountBetw = Application.CountIf(iRange, "" & lowNum) - _
Application.CountIf(iRange, "=" & hiNum)
ElseIf inclLow = True And inclHi = False Then
CountBetw = Application.CountIf(iRange, "=" & lowNum) - _
Application.CountIf(iRange, "=" & hiNum)
ElseIf inclLow = False And inclHi = True Then
CountBetw = Application.CountIf(iRange, "" & lowNum) - _
Application.CountIf(iRange, "" & hiNum)
End If
End Function
Alan Beban
Rick Rothstein (MVP -
VB) wrote:
What do you mean by "between"? If the 25 and 40 are to be excluded...
=COUNTIF(A1,"<40")-COUNTIF(A1,"<=25")
If they are to be included...
=COUNTIF(A1,"<=40")-COUNTIF(A1,"<25")
Note the different "<", "<=", "" and "=".
Rick
"benny" wrote in message
...
Is there a way to use the Count if function to count if a value is
between 25
and 40?
Using Excel 2003