+ Reply to Thread
Results 1 to 5 of 5

Display Listbox values

Hybrid View

  1. #1
    Registered User
    Join Date
    09-29-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    77

    Display Listbox values

    Hi,

    I'm sure this is a simply one, but I was wondering if anybody could tell me the best way to display the value of three seperate listboxes as a string of text in a seperate cell.

    So for example:

    Listbox1 = London
    Listbox2 = House
    Listbox3 = SE7

    So in cell A1 its says

    "London House SE7"

    Many thanks in advance

    Macro1
    Last edited by Macro1; 04-08-2010 at 09:31 AM.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,997

    Re: Display Listbox values

    What kind of listboxes and where are they located?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Display Listbox values

    See attached for basic example using listboxes from Forms and Active-X controls.

    A Forms Listbox returns an index value to a linked cell, so you will need to do a look up in order to join the text strings.

    Basic code for Forms list box (assigned to a button). Linked cells are on row1, look up cells are on row2 and the code writes the string to cell A10.

    Sub Create_Text()
    
        Range("A10").Value = Range("A2").Text & " " & Range("B2").Text & " " & Range("C2").Text
    
    End Sub
    With an Active-X listbox you can directly join the value in the control.
    Private Sub CommandButton1_Click()
    
        With Me
            
            Sheet1.Range("A10").Value = .ListBox1.Value & " " & .ListBox2.Value & " " & .ListBox3.Value
            .Hide
        
        End With
    
    End Sub
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  4. #4
    Registered User
    Join Date
    09-29-2009
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    77

    Re: Display Listbox values

    Thanks Guys,

    They are Control Toolbox Listboxes located on a worksheet. Palmetto that code worked a treat.

    Many Thanks

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Display Listbox values

    Glad you got the solution you needed.
    Please mark this thread as [SOLVED] by going to YOUR first post and clicking on Thread Tools, then Go Advanced and choose the solved prefix.

+ 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