- Sub yy()
- Dim Arr, i&, Brr, Arr1, aa
- Dim d, k, t, Crr(1 To 4)
- Arr = [c4].CurrentRegion
- [o4:ca7].ClearContents
- ReDim Brr(1 To UBound(Arr), 1 To 3)
- For i = 1 To UBound(Arr)
- mx = Application.Max(Application.Index(Arr, i, 0))
- mn = Application.Small(Application.Index(Arr, i, 0), 1)
- de = Application.Small(Application.Index(Arr, i, 0), 2)
- Brr(i, 1) = Format(mn & de, "00")
- Brr(i, 2) = Format(mn & mx, "00")
- Brr(i, 3) = Format(de & mx, "00")
- Next
- Set d = CreateObject("Scripting.Dictionary")
- For Each ar In Brr
- d(ar) = d(ar) + 1
- Next
- k = d.keys
- t = d.items
- For i = 0 To UBound(k)
- Select Case t(i)
- Case 4
- Crr(1) = Crr(1) & k(i) & ","
- Case 3
- Crr(2) = Crr(2) & k(i) & ","
- Case 2
- Crr(3) = Crr(3) & k(i) & ","
- Case 1
- Crr(4) = Crr(4) & k(i) & ","
- End Select
- Next
- For i = 1 To 4
- If InStr(Crr(i), ",") Then
- Crr(i) = Left(Crr(i), Len(Crr(i)) - 1)
- If InStr(Crr(i), ",") Then
- aa = Split(Crr(i), ",")
- Cells(i + 3, 15).Resize(1, UBound(aa) + 1) = aa
- Cells(i + 3, 15).Resize(1, UBound(aa) + 1).Sort Key1:=Cells(i + 3, 15), Order1:=xlAscending, Header:=xlGuess, _
- OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, SortMethod _
- :=xlPinYin, DataOption1:=xlSortTextAsNumbers
- Else
- Cells(i + 3, 15) = Crr(i)
- End If
- End If
- Next
- End Sub
复制代码 |