|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 汇总()
Dim ar As Variant
Dim br()
Dim sh As Worksheet
ReDim br(1 To 100000, 1 To 9)
For Each sh In Sheets
If sh.Index > 1 Then
r = sh.Cells(Rows.Count, 4).End(xlUp).Row
ar = sh.Range("b6:j" & r)
For i = 2 To UBound(ar)
If Trim(ar(i, 4)) <> "" Then
n = n + 1
br(n, 1) = n
For j = 2 To UBound(ar, 2)
br(n, j) = ar(i, j)
Next j
End If
Next i
End If
Next sh
If n = "" Then MsgBox "没有需要汇总的数据!": End
With Sheets("文件总目录(汇总)")
rs = .Cells(Rows.Count, 2).End(xlUp).Row
If rs >= 7 Then .Range("b7:j" & rs).Borders.LineStyle = 0: .Range("b7:j" & rs) = Empty
.[b7].Resize(n, UBound(br, 2)) = br
.[b7].Resize(n, UBound(br, 2)).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub |
|