I need to "return" an array of objects from a function that I created using VBA. When I try to set the function as an array, it gives me an error message saying
Object required.
I am not very used to VBA and I cannot fix it. Here is the function code:
Function sortedList(listRange As Integer, tempList() As ship) As ship
Dim temp As ship
Set temp = Nothing
For i = listRange - 10 To 1 Step -1
For j = 2 To listRange - 10
If tempList(j - 1).Arrival > tempList(j).Arrival Then
Set temp = tempList(j - 1)
Set tempList(j - 1) = tempList(j)
Set tempList(j) = temp
End If
Next j
Next i
'return tempList - how?
Set sortedList = tempList
End Function
Ship- This is the "class" that I created. tempListis an array of objects from a class Shipthat I need to return from a function sortedList.
The function works, it's just the return part that I cannot do.
Thanks for the help. If you need more information let me know!
source
share