|
第一问题:- Sub test()
- Application.ScreenUpdating = False
- r = Range("a1", [a1].End(4))
- For i = 1 To UBound(r)
- a = Split(r(i, 1), "-")
- For j = 0 To UBound(a)
- a(j) = Format(a(j), "0000")
- Next
- r(i, 1) = Join(a)
- Next
- [b1].Resize(UBound(r)) = r
- [a1:b1].Resize(UBound(r)).Sort [b1]
- [b:b] = ""
- Application.ScreenUpdating = True
- End Sub
复制代码 第二问题:- Function F(s, Optional n%)
- With CreateObject("VBSCRIPT.REGEXP")
- .Pattern = "\d+"
- F = .Replace(s, "")
- If n = 0 Then F = Replace(s, F, ""): If F = "" Then F = 1
- End With
- End Function
复制代码 |
|