Function return Collection

  • Thread starter Thread starter MrJingles
  • Start date Start date
M

MrJingles

Guest
I've created an object, it reads Excel data .....
So that is working fine...........
The problem is I want to know if I use the collection properly
===============================================
===============================================
Public Function getCustomerIds() As Collection
Dim c As New Collection
Dim counter as integer
Dim v As Variant
For Each v In obj_Excel.Worksheets(excelsheet).Range(excelcustomerrangeid)
x.Add Item:=v, key:=counter
counter = counter+1
Next

getCustomerIds = x <-- Error 449 : Argument not optional
End Function
==============================================

The part where I call the function:
Dim c As New Collection
Dim oo_Excel A New objExcel
===============================================
===============================================

c = oo_Excel.getCustomerIds() //this will call the function and raise the error 449 does anybody know how this works ??????? I cant find it
 
c or x, and Set...

Is there confusion between c and x? Is x declared anywhere?

Also, object assignments require the Set keyword, like...
Set getCustomerIds = c
 

Users who are viewing this thread

Back
Top Bottom