calculating average from an array

M

Mike D

I have an array like

array = "1,2,3|,2,4,6| ...)

There will be an unknown number a values between the | and an uknown total
number of values. I need to get the average of the number between each of
the |'s. Any ideas how to handle that?

Mike
 
A

Andrew Zamkovoy

Hello,

MyNewArray1 = Split (array, "|")
MyNewArray2 = Split (array, ",")

With best regards,
 
D

dlbjr

Function GetUniqueAvg(strData)
If Len(strData) > 0 Then
ar1 = Split(strData,"|")
For i = 0 To UBound(ar1)
strItem = ar1(i)
If Len(strItem) > 0 Then
ar2 = Split(strItem,",")
intTotal = 0
For ii = 0 To UBound(ar2)
If IsNumeric(ar2(ii)) Then
intTotal = CDbl(intTotal) + CDbl(ar2(ii))
End If
Next
ar1(i) = CDbl(intTotal) / CDbl(UBound(ar2) + 1)
Else
ar1(i) = 0
End If
Next
GetUniqueAvg = Join(ar1,",")
End If
End Function

'dlbjr
'Pleading sagacious indoctrination!
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top