|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Set reg = VBA.CreateObject("vbscript.regexp")
- k = Sheets(1).Cells(65536, 1).End(xlUp).Row
- With reg
- .Global = True
- .Pattern = ".*?([^()贴]+?)(\d+\D)?(?=()"
- For i = 5 To k
- arr = VBA.Split(.Replace(Sheets(1).Cells(i, 1), "$1\$2"), "")
- Sheets(1).Cells(i, 6) = arr(UBound(arr))
- t1 = "": t2 = ""
- For j = 0 To UBound(arr) - 1
- If j Mod 2 Then
- t1 = t1 & arr(j) & " "
- Else
- t2 = t2 & arr(j) & " "
- End If
- Next j
- Sheets(1).Cells(i, 5) = VBA.Trim(t1)
- Sheets(1).Cells(i, 4) = VBA.Trim(t2)
- Next i
- End With
- End Sub
复制代码 |
|