Hi!
I have a Userform with multiple listboxes. The first listbox lists all the sheets in the workbook. Two buttons let the user transfer the chosen sheets to Listbox1 and Listbox3.
After having the sheet names in both listboxes I would like to just copy the values in the listboxes to cells D1 and D2 in Sheet1.
Unfortunately it doesn't work. Here is the bit of code that should do the copy paste-part
So basically it should always copy the first entry in the listbox.
Thanks for your help
I have a Userform with multiple listboxes. The first listbox lists all the sheets in the workbook. Two buttons let the user transfer the chosen sheets to Listbox1 and Listbox3.
After having the sheet names in both listboxes I would like to just copy the values in the listboxes to cells D1 and D2 in Sheet1.
Unfortunately it doesn't work. Here is the bit of code that should do the copy paste-part
Code:
Private Sub CommandButton3_Click()
Dim myvalue As String
Dim tmpMsg As String
Dim i As Long
ThisWorkbook.Activate
With ThisWorkbook
Dim TheArray As Variant
Dim TheRange As Range
TheArray = ListBox1.List(0)
Set TheRange = Range("D1")
TheArray = ListBox3.List(0)
Set TheRange = Range("D2")
TheRange = TheArray
End With
So basically it should always copy the first entry in the listbox.
Thanks for your help