+ Reply to Thread
Results 1 to 6 of 6

Getting the number of elements in a user defined type

  1. #1
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Getting the number of elements in a user defined type

    Hi,

    Let's say I have user-defined type:

    Please Login or Register  to view this content.
    The type has three elements (Name, Age, Pets). Is there some way that I can return the number of elements of a UDT like above?

    Thanks a lot for reading!

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Getting the number of elements in a user defined type

    No, there isn't. This would require reflection, which VBA does not support.

    Depending on what you are actually trying to do, there may be other solutions

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question

    Hi !

    Maybe reading the code via the CodeModule object of a VBComponent object from the VBProject object …

  4. #4
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Getting the number of elements in a user defined type

    Thanks a lot for that - "Reflection" is new concept for me, thanks for letting me know about it!

  5. #5
    Registered User
    Join Date
    02-10-2013
    Location
    Frankfurt, Germany
    MS-Off Ver
    Excel 2003
    Posts
    57

    Re: Getting the number of elements in a user defined type

    Thanks for info - I'll certainly look into that.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,758

    Re: Getting the number of elements in a user defined type

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. User-defined type not defined when copying macro from one workbook to another
    By Mogles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2018, 08:08 AM
  2. Replies: 4
    Last Post: 06-28-2016, 05:38 PM
  3. Replies: 2
    Last Post: 06-26-2016, 02:17 AM
  4. [SOLVED] take user-defined array elements as a group?
    By njs27 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-31-2015, 06:52 PM
  5. [SOLVED] User-defined type not defined on Copy to Clipboard Macro
    By vamosj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2015, 11:31 AM
  6. [SOLVED] MSForms.CommandButton = User-defined Type not defined
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2015, 07:35 AM
  7. [SOLVED] Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1