Results 1 to 3 of 3

Thread: Adding UDT to a Collection
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jul 2009
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Adding UDT to a Collection

    Hi all

    When I try to add a UDT (defined using public type in the declarations section of a module) to a collection I get a compile error along the lines of 'Only user-defined types defined in a public object module can be coerced to or from...'. Am I doing something wrong or is it just that user-defined types cannot be added to a collection at all? Sorry if I'm repeating a previous post, I searched for a while and couldn't find anything.

    Paul

  2. #2
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,795
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: Adding UDT to a Collection

    You can't add UDTs to a Collection as far as I know. If you need a Collection, you'll need a class instead; otherwise you could use an array?

  3. #3
    New Member
    Join Date
    Jul 2009
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Adding UDT to a Collection

    Hi Rory

    I'd figured it just wasn't possible, thanks, and I'll be fine with an array, I just have to be a bit more careful!!

    Thanks for the speedy reply

    Paul

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •