|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 统计()
Dim ar As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With ActiveSheet
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "数据源为空!": End
ar = .Range("a1:f" & r)
Dim br()
ReDim br(1 To UBound(ar), 1 To 5)
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
zd = ar(i, 1) & "|" & ar(i, 2) & "|" & ar(i, 4) & "|" & ar(i, 5)
t = d(zd)
If t = "" Then
k = k + 1
d(zd) = k
t = k
br(k, 1) = ar(i, 1)
br(k, 2) = ar(i, 2)
br(k, 4) = ar(i, 5)
End If
If br(t, 3) = "" Then
br(t, 3) = ar(i, 3)
Else
br(t, 3) = br(t, 3) & "/" & ar(i, 3)
End If
br(t, 5) = br(t, 5) + ar(i, 6)
End If
Next i
.[k1].CurrentRegion.Offset(1).Borders.LineStyle = 0
.[k1].CurrentRegion.Offset(1) = Empty
.[k2].Resize(k, UBound(br, 2)) = br
.[k2].Resize(k, UBound(br, 2)).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub
|
|