Dim oRegExp As Variant Set oRegExp = CreateObject ("VBScript.RegExp" ) Dim MatchValue As Variant oRegExp.IgnoreCase = True ' Set whether to distinguish character case. oRegExp.Global = True ' Set global availability. oRegExp.Pattern = "TPP [0-9] {8}" ' 8-digit code at the beginning of TPP Set MatchValue = oRegExp.Execute ("<string>") If MatchValue.Count> 0 then
Msgbox.MatchValue (0) .Value
End if