I have created a custom collection class, in a class module, in Excel. I want to put a function to populate the collection with some custom objects, so I can pass one or more objects at one time.
The function I created is:
Public Sub Add( Object1 As customClass, _
Optional Object2 As customClass, _
Optional Object3 As customClass, _
Optional Object4 As customClass, _
Optional Object5 As customClass)
The problem is that I don't know how to detect how many args were passed to the function... How can I detect them?
In the other hand I was trying something like this:
Dim i as integer
for i = 1 to 5
If Not IsMissing("Object" & i) then MyCollection.Add "Object" & i
Next i
... buy obviously it does not work.
How can I do it in an elegant and simple way?