Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a set of new collections used to store lists of data. I now wish to
sort these collections in order and have a developed a general purpose function to do just that. However I wish to pass the name of the collection to my sort routine and I get an error "Argument not optional" as if the name of the collection is not recognised as a collection. Basic code structure as follows ' main code Dim cA as new collection Dim cB as new collection ' code that fills collection removed (that works ok) Call SortCollection(cA) '<--- this line fails, although cA is a collection and contains data End main code ' SORT FUNCTION Function SortCollection(mCol As Collection) ' sort the collection into order Dim i As Long, j As Long For i = 1 To mCol.Count - 1 For j = i + 1 To mCol.Count If mCol(i) mCol(j) Then Swap1 = mCol(i) Swap2 = mCol(j) mCol.Add Swap1, befo=j mCol.Add Swap2, befo=i mCol.Remove i + 1 mCol.Remove j + 1 End If Next j Next i End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
type mismatch error when passing collection byRef | Excel Programming | |||
Passing Objects from Excel VBA collection to a VB6 DLL | Excel Programming | |||
How to retain collection in function? | Excel Programming | |||
Error with passing collection as parameter | Excel Programming | |||
Collection Function | Excel Programming |