COUNTBETWEEN
Counts number of values between value1 and value2
Remarks
* The values can be numbers or dates.
* For instructions on how to add a function to a workbook refer to the page under Inserting Functions
* The equivalent JavaScript function is COUNTBETWEEN
Public Function COUNTBETWEEN( _
ByVal rgeValue As Range, _
ByVal min_Value As Single, _
ByVal max_value As Single, _
Optional ByVal bInclusive As Boolean = True) As Variant
Dim objcell As Range
Dim itotalcells As Integer
itotalcells = 0
If (rgeValue.Cells.Count > 10000) Then
COUNTBETWEEN = "no column references"
Exit Function
End If
If (bInclusive = True) Then
For Each objcell In rgeValue
If (objcell.Value >= min_Value) And (objcell.Value <= max_value) Then
itotalcells = itotalcells + 1
End If
Next objcell
End If
If (bInclusive = False) Then
For Each objcell In rgeValue
If (objcell.Value > min_Value) And (objcell.Value < max_value) Then
itotalcells = itotalcells + 1
End If
Next objcell
End If
COUNTBETWEEN = itotalcells
End Function
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext