Sub Collect()
Dim arr, brr(), Str, r&, n&, k&, LastRow&, sht As Worksheet
ReDim brr(1 To 50000, 1 To 4)
Application.ScreenUpdating = False
For Each sht In Worksheets
If sht.Name <> "重大异常履历" Then
arr = sht.UsedRange
For r = 4 To UBound(arr)
If Trim(arr(r, 3)) = "" Then arr(r, 3) = arr(r - 1, 3)
If Trim(arr(r, 4)) <> "" And Trim(arr(r, 5)) = "" Then arr(r, 5) = arr(r, 4)
If arr(r, 8) = "1" Then
n = n + 1
brr(n, 1) = arr(1, 1)
brr(n, 2) = arr(r, 3)
brr(n, 3) = arr(r, 4)
brr(n, 4) = arr(r, 5)
End If
Next r
End If
Next sht
With Sheets("重大异常履历")
.UsedRange.Offset(2) = Empty
.UsedRange.Offset(2).Borders.LineStyle = 0
.[a3].Resize(n, UBound(brr, 2)) = brr
.[a3].Resize(n, UBound(brr, 2)).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|