编辑将过滤的表添加到ListBox对象

我试图添加一个表的可见行到一个ListObject。 但是,代码运行不正常。

编辑:谢谢罗里的更正。 我现在得到的错误代码是1004,debugging器指向“ListBox1.List(I,1)= y.Range(1)”

这里是代码:

Private Sub UserForm_Activate() Dim TagArray As Variant TagArray = Split(Me.Tag, "-") 'This userform takes the worksheet and table name from another userform Dim x As Variant, y As Range, I As Long Set x = Worksheets(TagArray(0)).ListObjects(TagArray(1)).Range.SpecialCells(xlCellTypeVisible) For Each y In x I = y.Row ListBox1.List(I, 1) = y.Range(1) ListBox1.List(I, 2) = y.Range(2) ListBox1.List(I, 3) = y.Range(3) ListBox1.List(I, 4) = y.Range(4) ListBox1.List(I, 5) = y.Range(5) ListBox1.List(I, 6) = y.Range(6) ListBox1.List(I, 7) = y.Range(7) ListBox1.List(I, 8) = y.Range(8) ListBox1.List(I, 9) = y.Range(9) ListBox1.List(I, 10) = y.Range(10) 'I could probably use a for loop here. Not critical at this point though. Next End Sub 

任何帮助非常感谢,谢谢。