...为单元合并格,内容见下面,想用正则表达式在vba里面提取内容。_百 ...
发布网友
发布时间:2024-04-05 03:04
我来回答
共1个回答
热心网友
时间:2024-04-15 05:01
Sub test()
Dim oRegExp As Object
Dim oMatches As Object
Dim str As String
str = Range("a1") '数据源 可改为O10
Set oRegExp = CreateObject("VBScript.RegExp")
oRegExp.Pattern = "昨日.*?计划输气量(.*?)万方.*?计划外输(.*?)车.*?共(.*?)吨"
oRegExp.Global = True
Set oMatches = oRegExp.Execute(str)
For Each p In oMatches(0).Submatches
Debug.Print p '输出匹配的数据 321 34 54
Next
Set oRegExp = Nothing
Set oMatches = Nothing
End Sub