Please, I need to know how to total numeric values in a list box and divide that by the list count.
Printable View
Please, I need to know how to total numeric values in a list box and divide that by the list count.
let's assume that your listbox contains only numbers:
dim iSum as integer
Dim i as integer
For i = 0 To List1.ListCount - 1
isum = isum + List1.List(i)
Next i
MsgBox isum / List1.ListCount
Hi
Try something like :
Dim lTot As Long
Dim lCount As Long
For lCount = 0 To List1.ListCount - 1
If IsNumeric(List1.List(lCount)) Then
lTot = lTot + CLng(List1.List(Count))
End If
Next
MsgBox "Total = " & lTot
MsgBox "Average = " & lTot / List1.ListCount
Regards
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb