+ Reply to Thread
Results 1 to 3 of 3

How can I merge two strings and use them as a name?

Hybrid View

  1. #1
    Registered User
    Join Date
    01-10-2010
    Location
    Malmo, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    27

    How can I merge two strings and use them as a name?

    For example: I want to sort through a a bunch of textboxes and refer them to certain cells. I know I can have a string "TextBox" and then the looping number "nbr" and merge them into for instance TextBox1.
    But I can't figure out how to use this as a command. Like
    
    for nbr=1 to 5
    TextBox(nbr).caption=cells(nbr,2)
    next nbr
    Last edited by aron; 01-31-2010 at 06:07 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How can I merge two strings and use them as a name?

    If the textboxes are on a worksheet ie embedded
        For nbr = 1 To 5
            ActiveSheet.OLEObjects("TextBox" & nbr).Object.Value = cells(nbr,2)
        Next
    On a userform
        For nbr = 1 To 5
               Me.Controls("TextBox" & nbr).Value = Sheets("Sheet1").Cells(nbr, 2)
        Next
    Last edited by Marcol; 01-31-2010 at 08:32 AM. Reason: Additional info for forms

  3. #3
    Registered User
    Join Date
    01-10-2010
    Location
    Malmo, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    27

    Re: How can I merge two strings and use them as a name?

    Thank you so much!

+ 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