|
|
- Sub ykcbf() '//2025.11.3
- Dim reg As Object, matches As Object
- Dim namePart As String, amountPart As String
- Dim cell As Range
- Set reg = CreateObject("VBScript.RegExp")
- reg.Global = False
- reg.IgnoreCase = True
- reg.Pattern = "^\s*\d+[.、]\s*(.*?)([0-9]+(?:\s*元)?)\s*$"
- r = Cells(Rows.Count, 1).End(xlUp).Row
- For Each cell In Range("A2:A" & r)
- If Not IsEmpty(cell) Then
- If reg.Test(cell.Value) Then
- Set matches = reg.Execute(cell.Value)
- namePart = Trim(matches(0).SubMatches(0))
- amountPart = Trim(matches(0).SubMatches(1))
- cell.Offset(0, 2).Value = namePart
- cell.Offset(0, 3).Value = amountPart
- End If
- End If
- Next cell
- End Sub
复制代码
|
|