|
楼主 |
发表于 2018-5-24 01:11
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub zz()
- Dim a, b, c(), d As Object, n As Byte, tt As Boolean
- Dim k, t, tr
- tr = Timer
- Set d = CreateObject("scripting.dictionary")
- a = Range("f4:h" & [f1048576].End(3).Row).Value
- ReDim aa(1 To UBound(a), 1 To 2)
- With CreateObject("vbscript.regexp")
- .Pattern = "[0-9]{3,4}"
- .Global = True
- For i = 1 To UBound(a)
- For Each b In .Execute(a(i, 1))
- ReDim c(Len(b) - 1)
- For ii = 0 To UBound(c)
- c(ii) = Mid(b, ii + 1, 1)
- Next
- For jj = 0 To UBound(c)
- n = c(jj)
- For jjj = jj To UBound(c)
- If Val(c(jjj)) < n Then n = c(jjj): k = jjj: tt = True
- Next
- If tt Then tt = False: c(k) = c(jj): c(jj) = n
- Next
- d(ii - 2 & "@" & Join(c, "")) = ""
- Next
- a(i, 1) = ""
- For Each k In d.keys
- t = Split(k, "@"): n = t(0)
- a(i, n) = a(i, n) & "," & t(1)
- Next
- a(i, 1) = Mid(a(i, 1), 2)
- a(i, 2) = Mid(a(i, 2), 2)
- d.RemoveAll
- Next
- End With
- [g4].Resize(UBound(a), 2).NumberFormat = "@"
- [g4].Resize(UBound(a), 2) = a
- MsgBox Timer - tr
- End Sub
复制代码
|
|