Mid range

L

Ldappa

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?
 
L

Ldappa

Thanks Doug, that worked perfectly;)

I'm still a newbie trying to get the concepts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top