Adding UDT to a Collection

thepht

New Member
Joined
Jul 7, 2009
Messages
2
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
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,493
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
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?
 

thepht

New Member
Joined
Jul 7, 2009
Messages
2
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
 

Forum statistics

Threads
1,084,753
Messages
5,379,673
Members
401,620
Latest member
Ankur Teotia

Some videos you may like

This Week's Hot Topics

Top