PC Review


Reply
Thread Tools Rate Thread

Returning multiple items from a listbox

 
 
Kevlar
Guest
Posts: n/a
 
      15th Sep 2004
I've done a lot of unsuccessful searching on this forum for this answer
I want to be able to select multiple items from a list box and retur
the results to a range.

I've found this code;

Private Sub CommandButton1_Click()

For x = 0 To ListBox1.ListCount - 1

If ListBox1.Selected(x) = True Then
ActiveCell.Value = UserForm1.ListBox1.List(x)

End If
Next x

End Sub

But it returns all selections to a single cell. What I need it to do i
return the first selection to A1, the second to A2, etc.

By the way, this site is awesome and has never let me down, pleas
don't fail me now! :

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      16th Sep 2004
How about:

Private Sub CommandButton1_Click()
dim X as long
dim oRow as long

orow = 1
with worksheets("sheet1")
For x = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(x) = True Then
.cells(orow,"A").value = UserForm1.ListBox1.List(x)
orow = orow + 1
end if
Next x
end with
End Sub

"Kevlar <" wrote:
>
> I've done a lot of unsuccessful searching on this forum for this answer.
> I want to be able to select multiple items from a list box and return
> the results to a range.
>
> I've found this code;
>
> Private Sub CommandButton1_Click()
>
> For x = 0 To ListBox1.ListCount - 1
>
> If ListBox1.Selected(x) = True Then
> ActiveCell.Value = UserForm1.ListBox1.List(x)
>
> End If
> Next x
>
> End Sub
>
> But it returns all selections to a single cell. What I need it to do is
> return the first selection to A1, the second to A2, etc.
>
> By the way, this site is awesome and has never let me down, please
> don't fail me now!
>
> ---
> Message posted from http://www.ExcelForum.com/


--

Dave Peterson
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning selected items in a listbox into another listbox DShikotra Webmaster / Programming 0 8th Jan 2008 03:25 PM
Listbox move multiple selected items to second listbox K B Microsoft ASP .NET 2 8th Jan 2007 12:16 PM
Moving listbox item from listbox to listbox Kevin Quigley Microsoft Dot NET 2 2nd Jun 2004 11:34 AM
Deleted items keep returning to my deleted items folder DSerum Microsoft Outlook Discussion 0 31st Mar 2004 05:15 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Microsoft Excel Programming 0 22nd Oct 2003 12:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:54 PM.