+ Reply to Thread
Results 1 to 4 of 4

Create an Object from string and variable

  1. #1
    Registered User
    Join Date
    11-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Create an Object from string and variable

    Hi everyone,

    I have many textboxes on a Form named (tbx1, tbx2, tbx3, ect..). I am using a loop to cut down on code as I have 120 textboxes.

    How do I create an object variable using the string "tbx" and i as the loop variable? (resulting in "tbx1" during the first run, "tbx2" during the second, ect..)

    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    Re: Create an Object from string and variable

    Please Login or Register  to view this content.
    ?

  3. #3
    Registered User
    Join Date
    11-25-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Create an Object from string and variable

    When I run it, I actually don't even make it to that part of the code... I get an error on line:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    How do I name the variable "tbx" & i ("tbx"string and "i" loop integer variable) so that VBA will recognize it as the name of my controls?

    Thanks for the help

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

    Re: Create an Object from string and variable

    Should work if you have controls named tbx1 to tbx120

    Please Login or Register  to view this content.

+ 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