|
'在数组中求和,平均,最大,最小,极大,极小值等
Sub test()
arr = [b2:c9]
'MsgBox WorksheetFunction.Sum(arr)
'MsgBox WorksheetFunction.Average(arr)
'MsgBox WorksheetFunction.Max(arr)
'MsgBox WorksheetFunction.Min(arr)
'MsgBox WorksheetFunction.Small(arr, 2)
MsgBox WorksheetFunction.Large(arr, 2)
End Sub
Sub test2()
Dim arr1(1 To 99)
arr = [b2:c9]
For Each a In arr
If a >= 80 Then
n = n + 1
arr1(n) = a
End If
Next
MsgBox WorksheetFunction.Average(arr1)
End Sub
|
|