G
Guest
I've posted this before but did not get a response. I've seen many posts on
how to get MAX and MIN range of an array of numbers but how do i get the MID
range. I have three values say 18,17,15. I can get MAX MIN but when I try to
get 17 it comes out 18.
Here's the code I tried to adapt:
Function MidOfList(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMid As Variant 'Mid value found so far.
varMid = Null 'Initialize to null
For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Or IsDate(varValues(i)) Then
*** If varMid <= varValues(i) Then
*** If varMid >= varValues(i) Then
'do nothing
Else
varMid = varValues(i)
End If
End If
End If
Next
MidOfList = varMid
End Function
What am I doing wrong?
how to get MAX and MIN range of an array of numbers but how do i get the MID
range. I have three values say 18,17,15. I can get MAX MIN but when I try to
get 17 it comes out 18.
Here's the code I tried to adapt:
Function MidOfList(ParamArray varValues()) As Variant
Dim i As Integer 'Loop controller.
Dim varMid As Variant 'Mid value found so far.
varMid = Null 'Initialize to null
For i = LBound(varValues) To UBound(varValues)
If IsNumeric(varValues(i)) Or IsDate(varValues(i)) Then
*** If varMid <= varValues(i) Then
*** If varMid >= varValues(i) Then
'do nothing
Else
varMid = varValues(i)
End If
End If
End If
Next
MidOfList = varMid
End Function
What am I doing wrong?