|
Sub 汇总()
Dim ar As Variant
Dim arr()
ReDim arr(1 To 50000, 1 To 4)
For Each sh In Sheets
If sh.Name <> "汇总表" Then
r = sh.Cells(sh.Rows.Count, 2).End(xlUp).Row
ar = sh.Range("a1:g" & r)
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
n = n + 1
arr(n, 1) = ar(i, 1)
arr(n, 2) = ar(i, 2)
arr(n, 3) = ar(i, 7)
arr(n, 4) = sh.Name
End If
Next i
End If
Next sh
If n = "" Then MsgBox "没有需要汇总的数据!": End
With Sheets("汇总表")
.[a1].CurrentRegion.Offset(1).Borders.LineStyle = 0
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(n, 4) = arr
.[a2].Resize(n, 4).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub
|
评分
-
2
查看全部评分
-
|