Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello ksnapp
Here's some example code: Sub AverageOfCollection() 'Leo Heuser, 16 Apr. 2004 Dim CollSum As Double Dim Counter As Long Dim TestArray As Variant Dim TestColl As New Collection TestArray = Array(1, 3, 4, 6, 7) On Error Resume Next For Counter = LBound(TestArray) To UBound(TestArray) TestColl.Add Item:=TestArray(Counter) Next Counter For Counter = 1 To TestColl.Count CollSum = CollSum + TestColl(Counter) Next Counter MsgBox "Average is: " & CollSum / TestColl.Count End Sub -- Best Regards Leo Heuser Followup to newsgroup only please. "ksnapp " skrev i en meddelelse ... hello i need the average of a collection val is the name of a collection, here is the line of code: a = application.worksheetfunction.average(val) I tried this and it get an run time error 1004 unable to get the average property of the worksheet function. Is there something wrong with my VBA or is it that I can't use a collection like this? Is there a way to average a collection? I have tried to average numbers in the argument list and it works just fine. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Averageing monthly data by type | Excel Discussion (Misc queries) | |||
AVERAGEing non contiguous rows | Excel Discussion (Misc queries) | |||
Averageing Costs | Excel Discussion (Misc queries) | |||
Reset New Collection | Excel Programming | |||
2 Collection questions | Excel Programming |