excel - Why can't I add my UDT to a collection? -


i'm trying write small vba script grab data in 1 excel worksheet , store in collection variable. i'm new vba please bear me. i've created type(struct) keep data neat , organized, when try add collection compiler error.

here code:

option explicit public type cersositem     cdate date     ccompanycode integer     cl1code integer     cl2code integer     citemtype string     citemname string     citemamount double end type  public sub main() dim thelist collection set thelist = extractbooks() end sub  public function getblankcersositem() cersositem 'intentionally blank end function  public function extractbooks() dim thelist new collection dim thebook workbook set thebook = workbooks.open("lolpathnamehere") dim booksheet worksheet set booksheet = thebook.sheets(5) dim i, j integer dim tempitem cersositem set tempitem = new cersositem 'i have taken out line test = 2 booksheet.cells.specialcells(xlcelltypelastcell).row     tempitem         .cdate = booksheet.range("a" & i)         .ccompanycode = booksheet.range("b" & i)         .cl1code = booksheet.range("c" & i)         .cl2code = booksheet.range("d" & i)         .citemtype = booksheet.range("e" & i)         .citemname = booksheet.range("f" & i)         .citemamount = booksheet.range("g" & i)     end     thelist.add (tempitem)     set tempitem = getblankcersositem() next set extractbooks = thelist end function 

i getting error @ line: thelist.add (tempitem)
error i'm getting states:

only public user defined types defined in public object modules can used parameters or return types public procedures of class modules or fields of public user defined types

i used public keywork on type declaration , i'm having hard time figuring out compiler wants me do.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -