|
补上
- Option Explicit
- Sub 结果N()
- Dim Dic, Dfh, Djs, Arr, Brr(), k, Msg
- Dim Ms$, Mm$, Gjz$, i&, j&, n&, x&, y&, bz%
- Dim crr(1 To 10000)
- Application.ScreenUpdating = False
- Set Dic = CreateObject("scripting.dictionary")
- Set Dfh = CreateObject("scripting.dictionary")
- With Sheets("种类")
- Arr = .[a1].CurrentRegion
- For i = 1 To UBound(Arr)
- Ms = Trim(Arr(i, 2)) & "|" & Trim(Arr(i, 3)) & "|" & Trim(Arr(i, 4))
- Dfh(Ms) = Arr(i, 1)
- Next i
- End With
- With Sheets("原始数据")
- Arr = .[a1].CurrentRegion
- For i = 2 To UBound(Arr)
- Gjz = CStr(Trim(Arr(i, 1))) & "#" & CStr(DateValue(Arr(i, 2)))
- Ms = Trim(Arr(i, 3)) & "|" & Trim(Arr(i, 4)) & "|" & Trim(Arr(i, 5))
- Dic(Gjz) = Dic(Gjz) & "#" & Ms
- Next i
- End With
- ReDim Brr(1 To Dic.Count + 1, 1 To 500)
- For Each k In Dic.keys
- y = 2
- x = x + 1
- Brr(x, 1) = Split(k, "#")(0): Brr(x, 2) = Split(k, "#")(1)
- Ms = Right(Dic(k), Len(Dic(k)) - 1)
- Msg = Split(Ms, "#")
- Set Djs = CreateObject("scripting.dictionary")
- For i = 0 To UBound(Msg)
- Mm = Msg(i)
- y = y + 1
- Djs(Mm) = Djs(Mm) + 1
- bz = Djs(Mm) - 1
- 'If bz = 0 Then
- ' Brr(x, y) = CStr(Dfh(Mm))
- 'Else
- ' Brr(x, y) = CStr(Dfh(Mm) & "." & bz)
- 'End If
- Brr(x, y) = IIf(bz = 0, CStr(Dfh(Mm)), CStr(Dfh(Mm) & "." & bz))
- Next i
- j = j + 1
- crr(j) = y
- Next
- n = WorksheetFunction.Max(crr)
- With Sheets("结果")
- .Cells.Clear
- .[a1].Resize(Dic.Count, n) = Brr
- .Activate
- End With
- Set Dic = Nothing: Set Dfh = Nothing: Set Djs = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|