troubleshooting Question

Trying to understand how to build a macro around a very simple RegEx pattern

Avatar of John Carney
John CarneyFlag for United States of America asked on
Microsoft Excel
4 Comments2 Solutions252 ViewsLast Modified:
I'm starting to understand how to construct a pattern in RegEx, but I can't seem to get the hang of getting a macro to actually do something with a pattern. Pls take a look at the attached workbook and let me know how to construct my macro to get the desired result.

Sub MatchPattern()
[Myrange].Offset(0, 2).ClearContents
Dim RegEx      As VBScript_RegExp_55.RegExp
Dim rng1 As Range, cel As Range
    Set RegEx = New VBScript_RegExp_55.RegExp
    Set rng1 = [Myrange]
    With RegEx
        .MultiLine = False
        .Global = True
        .IgnoreCase = True
        .Pattern = "\d\s\w{1-3}"
    End With
    For Each cel In rng1
        cel.Offset(0, 2) = cel & " 999"
   Set rng1 = Nothing
    Set RegEx = Nothing
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros