By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,776 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,776 IT Pros & Developers. It's quick & easy.

how to copy selected item from listbox control

P: 10

I am currently trying to copy a single selected item from a listbox control in vba (excel).

So far I have got this code, which doesn't work.


Private Sub btnAddNewOrder_Click()

Dim sSelectedItem As String = ""

'If no item has been selected, show a error message box
If lst.SelectedItem = 0 Then
Call MsgBox("Please make a selection first")

'Copy Selected Row to a string array
lst.SelectedItem.CopyTo(sSelectedItem, 0)

'Paste string array into existing sheet (order) creating a unique orderID

End If

End Sub


Could someone please tell me what I am doing wrong as I am puzzled to what I am doing wrong.

I have used the SelectedItems function as described on msdn but could not find in depth info on the topic.

Thanks for looking!

Sep 10 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.