
Originally Posted by
Captain Database ...!!
Not sure why, but while it is working for "< 10"-type fields, it is returning a number in the hundreds-to-thousands for "10 - 20"-type fields.
That's because I hadn't thought that you had the 10-20 type fields. I had only thought they were going to be < X , > X, >= X or <= X. So I came up with this changed function:
Code:
Function ReturnMidpoint(varInput As Variant) As Long
Dim strHold As String
Dim strCase As String
Dim lng As Long
If Len(varInput & vbNullString) > 0 Then
If InStr(1, varInput, "-") > 0 Then
Dim varSplit As Variant
varSplit = VBA.Split(varInput, "-")
ReturnMidpoint = ((varSplit(1) - varSplit(0)) / 2) + varSplit(0)
Else
For lng = 1 To Len(varInput)
strCase = Mid(varInput, lng, 1)
Select Case strCase
Case 0 To 9
strHold = strHold & strCase
End Select
Next
If strHold <> varInput Then
ReturnMidpoint = strHold / 2
Else
ReturnMidpoint = varInput
End If
End If
Else
ReturnMidpoint = 0
End If
End Function