|
楼主 |
发表于 2018-9-17 22:14
|
显示全部楼层
Sub test()
Dim z, ar()
z = Sheets.Count
For x = 1 To z
Erase ar()
With Sheets(x)
If .Name <> "打印表" Then
num = WorksheetFunction.CountIf(.[j:j], "Y")
If num = 0 Then
GoTo us
End If
ReDim ar(1 To num, 1 To 10)
arr = .Range("a1:j" & .Cells(Rows.Count, 1).End(xlUp).Row)
For i = 1 To UBound(arr)
If arr(i, 10) = "Y" Then
N = N + 1
For II = 1 To 10
ar(N, II) = arr(i, II)
Next
End If
Next
Sheets("打印表").UsedRange.ClearContents
Sheets("打印表").[A1].Resize(UBound(ar), 10) = ar
Sheets("打印表").PrintPreview
End If
End With
us: Next x
End Sub
代码做了调整,现在这个代码只能运行几张表,运行成功几张表后,又蹦出下标越界。真的搞不懂为啥,前面都能运行一部分为啥会下标越界 |
|