- Sub t()
- Dim m%, arr, brr, crr, num%, p%, dic, d, i%, j, je%, s, r%
- Set dic = CreateObject("scripting.dictionary")
- Set d = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- ReDim crr(1 To 10, 1 To 23)
- With Sheets("分类")
- brr = .Range("b4:v" & .[b4].End(4).Row)
- For i = 2 To UBound(brr)
- For j = 2 To UBound(brr, 2)
- If brr(i, j) <> "" Then
- d(j & "|" & brr(1, j)) = d(j & "|" & brr(1, j)) & brr(i, j) & "|"
- End If
- Next j
- Next i
- End With
- With Sheets("录入")
- r = 1
- m = .[c5].End(4).Row
- arr = .Range("c5:e" & m)
- For i = 1 To UBound(arr)
- dic(arr(i, 1) & "|" & arr(i, 3)) = dic(arr(i, 1) & "|" & arr(i, 3)) + arr(i, 2)
- Next i
- For Each k In dic.keys
- crr(r, 1) = r
- crr(r, 2) = .[c3]
- crr(r, 3) = .[e3]
- s = Split(k, "|")
- For Each j In d.keys
- If InStr(d(j), s(0)) > 0 Then
- d2(j) = d2(j) + 1
- r = d2(j)
- crr(r, Int(Split(j, "|")(0)) + 2) = s(0) & "(" & dic(k) & "-" & dic(k) * s(1) & ")"
- Exit For
- End If
- Next j
- Next k
- Sheets("汇总").[b8].Resize(UBound(crr), UBound(crr, 2)) = crr
- End With
- Set dic = Nothing
- Set d = Nothing
- Set d2 = Nothing
- End Sub
复制代码 |