ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using a multi-select listbox to pull data (https://www.excelbanter.com/excel-programming/343048-using-multi-select-listbox-pull-data.html)

dreamz[_6_]

using a multi-select listbox to pull data
 

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

abc
def
ghi
jkl
mno

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

how can i do this?

thanks

--
dream
-----------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...fo&userid=2646
View this thread: http://www.excelforum.com/showthread.php?threadid=47692


Tom Ogilvy

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




dreamz[_7_]

using a multi-select listbox to pull data
 

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. :)


--
dreamz
------------------------------------------------------------------------
dreamz's Profile: http://www.excelforum.com/member.php...o&userid=26462
View this thread: http://www.excelforum.com/showthread...hreadid=476924



All times are GMT +1. The time now is 02:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com