![](http://tiebapic.baidu.com/forum/w%3D580/sign=0c7eca3dc144ebf86d716437e9f9d736/8cab1930e924b899ce1f8a0628061d950a7bf605.jpg?tbpicau=2024-09-12-05_c80f44cbeb1b60d5dec4c51d090396c4)
感谢回复
![](http://tb2.bdstatic.com/tb/editor/images/face/i_f02.png?t=20140803)
,筛选后的表格是这样的应该不是没数据的问题,我代码贴下面麻烦帮我看下怎么改好一些,谢啦🙏
代码:
Sub 添加2()
Dim ws1, ws2, i, k, arr, kai
Dim rg, j
Set ws1 = ThisWorkbook.Worksheets("采购单")
Set ws2 = ThisWorkbook.Worksheets("开单")
Set kai = ws2.ListObjects("TB_开单")
With ws1.Range("a1").CurrentRegion
.AutoFilter
.AutoFilter field:=2, Criteria1:=ws2.Range("$Q$4")
.AutoFilter field:=3, Criteria1:=ws2.Range("$U$4")
End With
If ws1.FilterMode Then
With ws1.AutoFilter.Range.SpecialCells(xlCellTypeVisible) ’这句还是会报错...
For i = 1 To .Areas.Count
k = k + .Areas(i).Rows.Count
Next
End With
arr = Range("e2:i" & k)
End If
For i = 1 To UBound(arr) '表格插入多行
kai.ListRows.Add Position:=1, AlwaysInsert:=True
Next
End Sub