+ Reply to Thread
Results 1 to 3 of 3

Object Name from a Variable, Doing Same Action to Multiple Object

  1. #1
    Registered User
    Join Date
    10-02-2010
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Object Name from a Variable, Doing Same Action to Multiple Object

    Good evening, everyone. I'm pretty much a beginner in VB and would like to ask some questions.

    Assume I have 1 variable (variable1) and some text boxes (textbox1, textbox2, etc).
    If I want to fill the text "texttexttext" to a textbox, which name is defined in variable1, how could I do that?

    Example:
    Variable1 = (name of something)
    (name of something).text ="texttexttext"


    Also, if there's any way to shorten this kind of code, i would like to know:
    (perhaps by making a "group" of objects, so i'll just have to call the group name to do the same thing with these objects?)
    textbox1.value = "aaa"
    textbox2.value = "aaa"
    textbox3.value = "aaa"
    . . . . . . .
    textbox99.value = "aaa"
    textbox100.value = "aaa"


    Thanks in advance.
    Last edited by 4Ferdinand; 06-22-2011 at 02:09 AM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Object Name from a Variable, Doing Same Action to Multiple Object

    4Ferdinand,

    For textboxes on a worksheet (ActiveX controls/OLEObjects):
    Please Login or Register  to view this content.


    For textboxes on a userform:
    Please Login or Register  to view this content.


    Hope that helps,
    ~tigeravatar

  3. #3
    Registered User
    Join Date
    10-02-2010
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2003
    Posts
    7

    Re: Object Name from a Variable, Doing Same Action to Multiple Object

    tigeravatar,

    Thanks for your help. I played a little with your code and found what I intended.

    I later learned that I can use this kind of code:
    Please Login or Register  to view this content.
    Last edited by 4Ferdinand; 06-22-2011 at 02:13 AM.

+ 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