J
Joe in Australia via OfficeKB.com
How do I create a function which returns a collection? I've tried this:
Function ListOfDates(ThisDate As Date, NumberofDays) As Collection
Dim MyLoop As Integer
For MyLoop = 1 To NumberofDays
ListOfDates.Add MyLoop, ThisDate + MyLoop - 1
Next MyLoop
End Function
But that gets me "Object variable or With block variable not set". On the
other hand, if I insert the line
ListOfDates = New Collection
it tells me that the arguments (to ListOfDates I assume) are not optional.
Function ListOfDates(ThisDate As Date, NumberofDays) As Collection
Dim MyLoop As Integer
For MyLoop = 1 To NumberofDays
ListOfDates.Add MyLoop, ThisDate + MyLoop - 1
Next MyLoop
End Function
But that gets me "Object variable or With block variable not set". On the
other hand, if I insert the line
ListOfDates = New Collection
it tells me that the arguments (to ListOfDates I assume) are not optional.