Hi,
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.
<code>
Private Sub btnAddNewOrder_ Click()
Dim sSelectedItem As String = ""
'If no item has been selected, show a error message box
If lst.SelectedIte m = 0 Then
Call MsgBox("Please make a selection first")
Else
'Copy Selected Row to a string array
lst.SelectedIte m.CopyTo(sSelec tedItem, 0)
'Paste string array into existing sheet (order) creating a unique orderID
Sheets("Order") .Select
ActiveSheet.Pas te
Sheets("Search" ).Select
End If
End Sub
</code>
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!
Rob
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.
<code>
Private Sub btnAddNewOrder_ Click()
Dim sSelectedItem As String = ""
'If no item has been selected, show a error message box
If lst.SelectedIte m = 0 Then
Call MsgBox("Please make a selection first")
Else
'Copy Selected Row to a string array
lst.SelectedIte m.CopyTo(sSelec tedItem, 0)
'Paste string array into existing sheet (order) creating a unique orderID
Sheets("Order") .Select
ActiveSheet.Pas te
Sheets("Search" ).Select
End If
End Sub
</code>
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!
Rob