Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Test_2()
- Dim oMatch As Object
- Dim iCount As Integer
- Dim oCell As Range
- Dim sPattern As String
- Set oCell = Application.ActiveCell
- sPattern = "(\w*) (\d*)"
- iCount = SRE(oCell.Value, sPattern, oMatch)
- If iCount > 0 Then
- oCell.Value = oMatch.Item(0).SubMatches.Item(0) & " == " & oMatch.Item(0).SubMatches.Item(1)
- End If
- Set oMatch = Nothing
- End Sub
- Function SRE(sString As Variant, sPattern As String, oResult As Object) As Integer
- Dim oRegEx As Object
- Set oRegEx = CreateObject("VBscript.RegExp")
- With oRegEx
- .MultiLine = False
- .Global = False
- .IgnoreCase = True
- .MultiLine = True
- .Pattern = sPattern
- Set oResult = .Execute(sString)
- End With
- Set oRegEx = Nothing
- SRE = oResult.Count
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement