+ Reply to Thread
Results 1 to 5 of 5

Help with looping over pre-defined list of objects

  1. #1
    Forum Contributor
    Join Date
    08-22-2017
    Location
    USA
    MS-Off Ver
    2016 WINDOWS and MAC
    Posts
    294

    Help with looping over pre-defined list of objects

    Hi,

    I am trying to eliminate some of the repetitiveness of my code. I have been reading about loops and arrays but I'm struggling to understand how I loop over a list of pre-defined userform objects.

    Here is the basics of my code (not full code)

    Please Login or Register  to view this content.
    'Userform write values to database:

    Please Login or Register  to view this content.


    For instance if I use,

    Please Login or Register  to view this content.
    I would like to just define some kind of list at the get-go of all my controls and their respective offset value. Then I can just loop through the list when I need to execute commands.

    I apologize for the noob questions.


    Thanks for the help.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Help with looping over pre-defined list of objects

    Something like this may give you the idea...
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    08-22-2017
    Location
    USA
    MS-Off Ver
    2016 WINDOWS and MAC
    Posts
    294

    Re: Help with looping over pre-defined list of objects

    jindon, thanks,

    I could in fact do that, but that only helps me until the order is no longer consecutive. For instance if...

    txtbox_location1.value = row 1
    txtbox_location2.value = row 2
    txtbox_location3.value = row 5
    txtbox_location4.value = row 9

    Then i am out of luck with this option.

    Thanks for your help with this.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Help with looping over pre-defined list of objects

    Then something like.
    Please Login or Register  to view this content.
    You could do some other ways using array(s).

  5. #5
    Forum Contributor
    Join Date
    08-22-2017
    Location
    USA
    MS-Off Ver
    2016 WINDOWS and MAC
    Posts
    294

    Re: Help with looping over pre-defined list of objects

    jindon,

    Thanks for the help. I think i'll stick with the For Loop for now. Its has tidied up my code a lot.

+ 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. setting up objects and extracting data from objects when of a user defined data type
    By whburling in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-30-2017, 12:40 PM
  2. Looping through Objects and giving them appropriate hyperlinks
    By JoeSkittles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2013, 08:30 AM
  3. Select all objects in a defined range
    By Kalutschi in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-15-2013, 06:19 AM
  4. Looping through a user defined type?
    By plh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2006, 12:40 PM
  5. Passing Arrays in User Defined Objects
    By Developer of the Caribbean in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2005, 10:05 PM
  6. User Defined Objects in VBA?
    By McManCSU in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-29-2005, 02:50 PM
  7. Looping Thru Objects in UserForms
    By RobC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2005, 07:06 PM

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