|
黄金万两︶ㄣ 发表于 2014-2-2 09:48
测试过,非常好。因早前上传附件不能体现出再有C列详址后的效果,所以我再更新附件了,老师有时间再帮助修 ... - Sub Macro1()
- Dim matchs As Object, arr, brr&(), i&
- arr = Range("b2:b" & Range("b" & Rows.Count).End(xlUp).Row)
- ReDim brr(1 To UBound(arr), 1 To 1)
- With CreateObject("VBScript.RegExp")
- .Global = True
- .Pattern = "[0-9]+"
- For i = 1 To UBound(arr)
- Set matchs = .Execute(arr(i, 1))
- If .test(arr(i, 1)) Then brr(i, 1) = matchs(0).Value
- Next
- End With
- With [d2].Resize(i - 1)
- .Value = brr
- Range("A2:D" & i).Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("D2"), Order2:=xlAscending, Header:=xlNo
- .Clear
- End With
- End Sub
复制代码 |
|