|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 记录汇总()
Dim ar As Variant
Dim br()
With ActiveSheet
r = .Cells(Rows.Count, 2).End(xlUp).Row
nf = .Cells(r, 2)
yf = .Cells(r, 3)
ts = .Cells(r, 4)
kh = .[a1]
rq = CDate(nf & "/" & yf & "/" & ts)
For i = r To 3 Step -1
rq_1 = CDate(.Cells(i, 2) & "/" & .Cells(i, 3) & "/" & .Cells(i, 4))
If rq_1 <> rq Then
ks = i
Exit For
End If
Next i
ar = .Range(.Cells(ks + 1, 1), .Cells(r, 18))
End With
ReDim br(1 To UBound(ar), 1 To 14)
For i = 1 To UBound(ar)
If ar(i, 2) <> "" Then
n = n + 1
br(n, 1) = ar(i, 2)
br(n, 2) = ar(i, 3)
br(n, 3) = ar(i, 4)
br(n, 4) = kh
For j = 5 To 11
br(n, j) = ar(i, j)
Next j
br(n, 12) = ar(i, 13)
br(n, 13) = ar(i, 18)
br(n, 14) = ar(i, 14)
End If
Next i
With Sheets("汇总")
x = .Cells(Rows.Count, 1).End(xlUp).Row + 1 '取得“汇总”表中最后一个空行的行号(即写入位置)
.Cells(x, 1).Resize(n, UBound(br, 2)) = br
End With
MsgBox "ok!"
End Sub
|
|