|
Option Explicit
Sub TEST6()
Dim ar, br, cr, i&, j&, r&, c&, iPosRow&, iPosCol&, strDigit$, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Worksheets(1).[A1].CurrentRegion.Value
ReDim br(1 To UBound(ar) * 2, 1 To UBound(ar))
r = 1: c = 1 ': br(1, 1) = "车牌号"
For i = 2 To UBound(ar)
cr = Split(ar(i, 4), ",")
For j = 0 To UBound(cr)
If Not dic.exists(cr(j)) Then
r = r + 1
dic(cr(j)) = r
br(r, 1) = cr(j)
End If
strDigit = "数据" & ar(i, 3)
If Not dic.exists(strDigit) Then
c = c + 1
dic(strDigit) = c
br(1, c) = strDigit
End If
iPosRow = dic(cr(j)): iPosCol = dic(strDigit)
br(iPosRow, iPosCol) = br(iPosRow, iPosCol) + 1
Next j
Next i
With Worksheets(1)
[H1].CurrentRegion.Clear
With .[H1].Resize(r, c)
.Value = br
.Borders.LineStyle = xlContinuous
.EntireColumn.AutoFit
End With
.Activate
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|