|
Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("Sheet1").UsedRange
For i = 4 To 13
Set d(arr(1, i)) = CreateObject("scripting.dictionary")
For j = 2 To UBound(arr)
If Not d(arr(1, i)).exists(arr(j, 3)) Then
Set d(arr(1, i))(arr(j, 3)) = CreateObject("scripting.dictionary")
End If
d(arr(1, i))(arr(j, 3))(arr(j, i)) = 1 + d(arr(1, i))(arr(j, 3))(arr(j, i))
Next j
Next i
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets(2).Select
Sheets(2).UsedRange.Offset(2).Clear
r = 2
For Each k In d.keys
rx = r + 1
Cells(rx, 1) = k
For Each kk In d(k).keys
r = r + 1
Cells(r, 2) = kk
For i = 3 To 7
Cells(r, i) = d(k)(kk)(Cells(2, i).Value) + 0
Next i
Next kk
Range(Cells(rx, 1), Cells(r, 1)).Merge
Next k
Sheets(2).UsedRange.Borders.LineStyle = xlContinuous
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
|
|