我用这个指令做了userForm:http://www.excel-easy.com/vba/examples/multiple-list-box-selections.html
我试着根据表做动态项目列表,
With ListBox_1
.RowSource =
Worksheets("warianty").ListObjects("in_").ListColumns(1).DataBodyRange
.ColumnHeads = True
.ColumnCount = 3
End With
它显示为空白,没有可供选择的列表 . 我使用对象表来获取动态范围 . 当然我可以使用其他解决方案,但这个似乎是可以实现的 .
然后我想将每个选定的项目复制到从第一行开始的其他表格 . 这是我尝试根据教程中的其他按钮修改的代码 .
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
除了改进代码之外,SB能告诉我为什么我不能只是'复制'列表ListBox.value或者某事?
1 回答
请尝试以下方式:
Code