【发布时间】:2019-06-08 07:42:15
【问题描述】:
我需要您的帮助,将数据从列表框移至工作表。 此列表框包含 14 列。如何将列表框中的行复制到工作表中?
Sub Post ()
Dim arr
Dim cnt As Integer
cnt = ListBox1.ListCount
arr = ListBox1.List
With Sheets("DATABASE").ListObjects(1)
.ListRows.Add
.DataBodyRange.Cells(.ListRows.Count, 1).Resize(cnt, 14) = arr
End With
ListBox1.clear
End Sub
********************** 更新 15-01-2019 17:30 ********************* * 我找到了这段代码,但它向下移动了 1 行,如下图所示
Private Sub CommandButton2_Click()
Dim i As Long
For i = 0 To ListBox1.ListCount
For x = 1 To 14
Sheets("Database").Range("B2").End(xlDown).Offset(i + 1, x - 1) =
ListBox1.List(i, x - 1) 'ListBoxl.List(i, x)
Next x
Next i
End Sub
【问题讨论】: