+ Reply to Thread
Results 1 to 5 of 5

Using Variables to Name Objects

  1. #1
    Registered User
    Join Date
    04-22-2012
    Location
    Syracuse, NY, USA
    MS-Off Ver
    Office 365
    Posts
    61

    Using Variables to Name Objects

    I apologize if this subject has already been covered but I tried to search for it and I kept getting a message saying that my search query wasn't specific enough

    Is it possible to use a variable to dynamically call objects. For example I have a function that refers to 7 different objects whose name only differs by a number at the end of them (CboItem1-CboItem7) that requires the same code executed upon them. Would it be possible to use a loop and variable procedure to produce the references? If so, what is the syntax for doing so? Having to repeat the same code seven or more times is going to be very time consuming to debug and update in the future.
    Reality is stranger than fiction.

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Using Variables to Name Objects

    where are the objects? if on a userform you can refer to
    Please Login or Register  to view this content.
    in a loop. you can also write a routine that takes a combobox as an argument and manipulates it so you only have one piece of processing code.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Using Variables to Name Objects

    duplicate post

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,083

    Re: Using Variables to Name Objects

    Should the "& n" be inside the brackets?

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Using Variables to Name Objects

    shoot-yes! sorry guys
    Please Login or Register  to view this content.
    is the correct code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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