LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default Passing Collection to function

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
type mismatch error when passing collection byRef Tara H Excel Programming 2 September 14th 07 05:56 PM
Passing Objects from Excel VBA collection to a VB6 DLL Dan[_50_] Excel Programming 6 February 15th 06 10:34 PM
How to retain collection in function? durex[_12_] Excel Programming 0 December 1st 05 12:41 AM
Error with passing collection as parameter McManCSU[_17_] Excel Programming 3 August 1st 05 06:19 PM
Collection Function Rob Excel Programming 2 March 5th 04 11:43 AM


All times are GMT +1. The time now is 06:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"