是不是你要的????我猜的
Sub 问题()
Dim reg, sols, a, b, c, d, r
Dim minv, minv2 As Long
Dim st As String
r = [a1].End(xlDown).row
Set reg = CreateObject("vbscript.regexp")
reg.Global = True
reg.Pattern = "\d+"
arr = [a1].CurrentRegion
For a = 1 To r
Set sols = reg.Execute(arr(a, 1))
For b = 0 To sols.Count - 1
st = st & "," & sols(b)
Next
Next
brr = Split(st, ",")
For a = 1 To UBound(brr, 1)
minv = brr(a)
minv2 = brr(a)
For b = a + 1 To UBound(brr, 1)
If brr(b) < minv Then
minv = brr(b)
r = b
End If
Next
If minv < brr(a) Then
brr(a) = brr(r)
brr(r) = minv2
End If
Next
c = 1
For a = 1 To UBound(arr, 1)
Set sols = reg.Execute(arr(a, 1))
crr = Split(arr(a, 1), ",")
If UBound(crr, 1) > 0 Then
b = 0
For d = 0 To UBound(crr, 1)
crr(d) = Replace(crr(d), sols(b), brr(c))
b = b + 1
c = c + 1
Next
arr(a, 1) = Join(crr, ",")
Else
For b = 0 To sols.Count - 1
arr(a, 1) = Replace(arr(a, 1), sols(b), brr(c))
c = c + 1
Next
End If
Next
[c1].Resize(UBound(arr, 1), 1) = arr
Set reg = Nothing
Set sols = Nothing
End Sub