View Single Post
 
Old 08-20-2018, 08:06 AM
davidlooney davidlooney is offline Windows 7 32bit Office 2016
Novice
 
Join Date: Jul 2018
Posts: 1
davidlooney is on a distinguished road
Default Regular Expressions

I’m trying to write a regular expression where the string matches “_Clauses” OR “_OL” but NOT “_Word”. Can anyone help? The OR part works, the NOT doesn’t.

Dim regex As Object, str As String
Set regex = CreateObject("VBScript.RegExp")

With regex
.Pattern = "_Clauses|_OL[^_Word]"
.Global = True
End With

For Each ws In ActiveWorkbook.Worksheets
str = ws.Name
Debug.Print regex.Test(str)
Next ws
Reply With Quote