Hi
How about creating a function to do the calculation, and working from there.
In the code below, I've dummied up a string with comma separated values. the function takes that string, a lower number and an upper number and returns the result.
Sub bbb()
Dim txtval As String
txtval = "1,2,3,4"
MsgBox myCalc(txtval, 2, 4)
End Sub
Function myCalc(strr As String, lwr As Long, upr As Long)
arr = Split(strr, ",")
denom = 0
numer = 0
For i = LBound(arr) To UBound(arr)
denom = denom + arr(i)
If CLng(arr(i)) >= lwr And CLng(arr(i)) <= upr Then
numer = numer + arr(i)
End If
Next i
myfunc = numer / denom
End Function
Hope that gets you going.
rylo
Bookmarks