|
Sub 截取部分内容()
Set reg = CreateObject("vbscript.regexp")
With reg
.Global = True
.Pattern = "_([一-龡]+部).+?(_\d+)"
End With
With Sheets(1)
myrow = .Cells(65536, 3).End(xlUp).Row
.Cells(2, 6).Resize(myrow, 2).ClearContents
For i = 2 To myrow
ss = .Cells(i, 3)
Set mm = reg.Execute(ss)
For Each qq In mm
For j = 0 To qq.submatches.Count - 1
If qq.submatches(j) <> "" Then
.Cells(i, j + 6) = qq.submatches(j)
End If
Next j
Next
Next i
End With
Set reg = Nothing
End Sub
|
|