ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   multi select listbox (https://www.excelbanter.com/excel-programming/301093-multi-select-listbox.html)

paul mueller

multi select listbox
 
Hi All,
In the line of code below I am trying to insert the checked items from
the multiselect-extended listbox into a1 and add next checked items to
the right. Its only copying the last item selected and placing it in
"IV1".
I cannot seem to get this to work.

For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
range("A1").Select
ActiveCell.Offset(0, 1).Value = Me.ListBox1.list(i)
End If
Next i



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

multi select listbox
 
I don't see anything that would write to IV1, but you are writing everything
to B1, so you would see only the last item in B1:

j = 0
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
range("A1").Offset(0, j).Value = Me.ListBox1.list(i)
j = j + 1
End If
Next i


"Paul Mueller" wrote in message
...
Hi All,
In the line of code below I am trying to insert the checked items from
the multiselect-extended listbox into a1 and add next checked items to
the right. Its only copying the last item selected and placing it in
"IV1".
I cannot seem to get this to work.

For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
range("A1").Select
ActiveCell.Offset(0, 1).Value = Me.ListBox1.list(i)
End If
Next i



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!




Bob Phillips[_6_]

multi select listbox
 
Paul,

Try this

For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
j=j+1
Cells(1,j).Value = Me.ListBox1.list(i)
End If
Next i


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul Mueller" wrote in message
...
Hi All,
In the line of code below I am trying to insert the checked items from
the multiselect-extended listbox into a1 and add next checked items to
the right. Its only copying the last item selected and placing it in
"IV1".
I cannot seem to get this to work.

For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
range("A1").Select
ActiveCell.Offset(0, 1).Value = Me.ListBox1.list(i)
End If
Next i



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 10:24 PM.

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