+ Reply to Thread
Results 1 to 4 of 4

"for each" loop in controls to populate user-defined type

  1. #1
    Registered User
    Join Date
    08-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2016, 32-bit
    Posts
    92

    Question "for each" loop in controls to populate user-defined type

    Hello all,

    Hoping someone can help.

    I have a user-defined type that I want to hold various data selected from a UserForm. I have the UserForm controls in a frame so that I can loop through them using something like this:
    Please Login or Register  to view this content.
    in order to capture the status of each item chosen (or not chosen). It fails in the If section on the line that begins with udtInputs and the error varies (depending on what I've tried to put in there)

    It seems to be in the right place (in the UserForm code), and while debugging, I can see that "pgmName" is how I want it (matching how I defined the user-defined type in the main Module). So, if the user chooses "All Programs" from the form (checkboxes), I would like
    Please Login or Register  to view this content.
    but I can't figure out how to get the syntax right.

    If it helps, here is the udt definition:
    Please Login or Register  to view this content.
    Thanks in advance!
    Last edited by njs27; 03-24-2015 at 04:58 PM. Reason: "replace" line was incorrect (old piece of code)

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,570

    Re: "for each" loop in controls to populate user-defined type

    Part of the problem is a missing underscore:
    udtInputs.AllPrograms = true
    v.s.

    Public Type ReportData
    All_Programs As Boolean
    Prog1 As Boolean
    Prog2 As Boolean

    ...etc
    End Type
    Ben Van Johnson

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: "for each" loop in controls to populate user-defined type

    You can't access the components of a UDT like that.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    08-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2016, 32-bit
    Posts
    92

    Re: "for each" loop in controls to populate user-defined type

    Quote Originally Posted by Norie View Post
    You can't access the components of a UDT like that.
    ugh. That was what I was afraid of.

    Any idea how I could assign the variables to them then? Would I have to maybe write them to a wkst and then read them back into the UDT from there?

+ 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. Error message: "Compile error. User-defined type not defined"
    By freckles81 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-13-2012, 09:37 AM
  2. "flexible" looping through a User Defined Type
    By broro183 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-28-2010, 08:41 PM
  3. Error message: "Compile error. User-defined type not defined"
    By lottesfog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2007, 06:38 PM
  4. "User-defined type not defined" error when trying to send e-mail
    By SupperDuck in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-02-2006, 02:40 AM
  5. [SOLVED] "User-defined type not defined" message in Excel
    By RW1946 in forum Excel General
    Replies: 0
    Last Post: 08-31-2005, 08:05 AM

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