|
Sub hz()
Application.ScreenUpdating = False
Dim ar As Variant, cr As Variant
Dim i As Long, rs As Long
Dim br()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("sheet1")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a2:d" & rs)
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" And Trim(ar(i, 3)) <> "" Then
If ar(i, 2) > 0 Then
zd = Trim(ar(i, 1)) & "|" & Trim(ar(i, 3))
t = d(zd)
If t = "" Then
k = k + 1
d(zd) = k
t = k
br(k, 1) = ar(i, 1)
br(k, 3) = ar(i, 3)
End If
br(t, 2) = br(t, 2) + ar(i, 2)
br(t, 4) = br(t, 4) + ar(i, 4)
End If
End If
Next i
r = .Cells(Rows.Count, 6).End(xlUp).Row
If r > 2 Then
.Range("f3:i" & r).Borders.LineStyle = 0
.Range("f3:i" & r) = Empty
End If
.[f3].Resize(k, UBound(br, 2)) = br
.[f3].Resize(k, UBound(br, 2)).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub
|
|