+ Reply to Thread
Results 1 to 4 of 4

Problem referencing a series of text boxes using the numbers in their names.

  1. #1
    Registered User
    Join Date
    02-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Problem referencing a series of text boxes using the numbers in their names.

    I'm fairly new to VBA and I'm building a form that has a large number of text boxes on it designed to show the contents of a 2d array. The boxes are sequentially named a1, a2, a3, etc. To populate those boxes from an array is there a way to reference the name of each box based on an incrementing number rather than write out a large number of a1.Value =, a2.Value =, etc statements?

    I tried a loop like this one

    for i = 1 to 10

    a(i).Value = array(i, 1)

    next i

    but the a(i).Value syntax is misinterpreted.

    I'm probably barking up the wrong tree and there's a better way to do this, any ideas would be appreciated
    Last edited by cptpies; 02-03-2012 at 11:18 AM. Reason: solved

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Problem referencing a series of text boxes using the numbers in their names.

    Assuming you are referring to a userform
    Please Login or Register  to view this content.
    Good luck.

  3. #3
    Registered User
    Join Date
    02-03-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Problem referencing a series of text boxes using the numbers in their names.

    Brilliant, works a treat. Many thanks OnErrorGoto0

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Problem referencing a series of text boxes using the numbers in their names.

    My pleasure. Please do not forget to mark the thread Solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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