+ Reply to Thread
Results 1 to 4 of 4

Reference Control by Name

  1. #1
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Reference Control by Name

    Hi Everyone

    I want to populate a number of text box controls on a userform using a For Next loop.

    For example to populate text box controls: txtMyVal1, txtMyVal2, txtMyVal3 using a loop which concatenates the string"txtMyVal" with the loop counter value.

    It is similar to the INDIRECT() function in Excel.

    Whilst I can build the string OK I don't know how to use this as the control's name.

    Is this possible?

    WIth thanks
    barry
    Last edited by barryleajo; 09-01-2010 at 06:34 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can you implement the Excel INDIRECT() function in VBA?

    Hi

    Within the For..Next loop with x as the loop counter

    Please Login or Register  to view this content.
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor
    Join Date
    06-19-2010
    Location
    Holywell, N Wales, UK
    MS-Off Ver
    Excel 2013
    Posts
    470

    Re: Can you implement the Excel INDIRECT() function in VBA?

    Hi Richard
    Very many thanks for your quick reply.
    Works a treat.
    It would have taken me ages to have uncovered this.
    Thanks for passing on your knowledge.
    I'll mark this as solved and tip your scales!
    barry

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Can you implement the Excel INDIRECT() function in VBA?

    Thanks Barry,

    Glad to have been able to help. That's why we're here.

    Rgds

+ 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