参与学习
- Sub t()
- Dim arr, m%, i%, r%, re, st, wb, n, tp
- Set re = CreateObject("vbscript.regexp")
- m = [a1].End(4).Row
- [b1:c100000].ClearContents
- wb = ""
- With re
- For i = 1 To m
- .Pattern = "Z[-\d]+\.\d+"
- .Global = True
- Set st = .Execute(Range("a" & i))
- n = InStr(Cells(i, 1), "F")
- If st.Count > 0 Then
- wb = st(0)
- Cells(i, 2) = Cells(i, 1)
- Cells(i, 3) = wb
- ElseIf n And wb <> "" Then
- tp = Mid(Cells(i, 1), n)
- Cells(i, 2) = Replace(Cells(i, 1), Mid(Cells(i, 1), n), wb) & " " & tp
- End If
- Next i
- End With
- Set re = Nothing
- End Sub
复制代码 |