|
- Private Sub Cmm()
- [B:B].ClearContents
- Dim a(), b()
- Set d = CreateObject("scripting.dictionary")
- For Each c In Range([A1], Cells(Rows.Count, 1).End(xlUp))
- s = Trim(c.Value)
- If Len(s) > 0 Then
- x = Split(s, ",")
- If UBound(x) = LBound(x) Then
- c.Offset(, 1) = s
- Else
- n = 0
- For j = LBound(x) To UBound(x)
- For i = 1 To Len(x(j))
- If (Asc(Mid(x(j), i, 1)) < 48) Or (Asc(Mid(x(j), i, 1)) > 57) Then n = n + 1 Else Exit For
- Next
- ReDim Preserve a(0 To j)
- ReDim Preserve b(0 To j)
- a(j) = Mid(x(j), 1, n)
- b(j) = CInt(Mid(x(j), n + 1))
- d(b(j)) = a(j)
- n = 0
- Next
- For ii = 0 To UBound(x)
- For jj = ii + 1 To UBound(x)
- If b(ii) > b(jj) Then
- TEMP = b(jj)
- b(jj) = b(ii)
- b(ii) = TEMP
- End If
- Next
- Next
- TEMP = ""
- s = ""
- kk = kk + 1
- For i = LBound(b) To UBound(b)
- If d.Exists(b(i)) Then s = s & d(b(i)) & b(i) & ","
- Next
- d.RemoveAll
- Erase a, b
- c.Offset(, 1) = s
- End If
- End If
- Next
- End Sub
复制代码 |
|