I did userForm with this instruction: http://www.excel-easy.com/vba/examples/multiple-list-box-selections.html
I tried to do dynamic item list based on table,
With ListBox_1
.RowSource =
Worksheets("warianty").ListObjects("in_").ListColumns(1).DataBodyRange
.ColumnHeads = True
.ColumnCount = 3
End With
it comes out blank with no list to Select from.I used object table to get dynamic range. Of course I can use other solution, but this one seemed achievable.
Then I want to copy each selected items to other table starting with first row. Here is code i tried to modify based on other button in tutorial.
Private Sub button_save_Click()
Dim counter As Integer
counter = 0
For i = 0 To ListBox_2.ListCount - 1
If ListBox_2.Selected(i - counter) Then
ListBox_2.copy (i - counter) 'it gives error here
Worksheets("dane wejściowe").ListObjects("Tabela41").DataBodyRange(1 + i, 1).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
counter = counter + 1
End If
End Sub
besides improving code can SB tell me why I can't just 'copy' list ListBox.value or sth?
Please try the below:
Code