+ Reply to Thread
Results 1 to 3 of 3

using a multi-select listbox to pull data

  1. #1
    Registered User
    Join Date
    08-19-2005
    Posts
    58

    using a multi-select listbox to pull data

    i need to create a dialog box that uses a multi-select listbox to pull data from another sheet (or workbook). for instance, i'd like a listbox that displays a list:

    abc
    def
    ghi
    jkl
    mno

    and so on, allowing the user to select from the box the elements of immediate interest. i'd like the listbox to know which elements were selected and pull only those pieces of data that are associated with those elements.

    how can i do this?

    thanks.

  2. #2
    Tom Ogilvy
    Guest

    RE: using a multi-select listbox to pull data

    for i = 0 to Listbox1.Listcount - 1
    if listbox1.Selected(i) then
    ' work with the listbox1.list(i)
    end if
    Next

    Multiselect is a property of the listbox which you can set in the properties
    window.

    --
    Regards,
    Tom Ogilvy




  3. #3
    Registered User
    Join Date
    08-19-2005
    Posts
    58
    thanks.

    i ended up writing this:

    Private Sub Compute_Click()
    Worksheets("Sheet1").Range("A1").Select
    For i = 0 To ListBox1.ListCount - 1
    If ListBox1.Selected(i) Then ActiveCell.Value = ListBox1.List(i)
    If ActiveCell.Value = "" Then ActiveCell.Select
    If ActiveCell.Value <> "" Then ActiveCell.Offset(1, 0).Select
    Next i
    Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Copy Worksheets("sheet2").Range("A1")
    Unload Me
    End Sub

    works perfectly.

+ 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