multi select listbox

P

Paul Mueller

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!
 
T

Tom Ogilvy

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
 
B

Bob Phillips

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top