I have a string (filename, actually), that I want to see how many instances there are of XNNNN and/or XNNNNN, where N is a numerical digit.
For example, if filename is "N1234 and N22522 - Content", then I would like to know that there are 2 matches and be able to analyze the 2 matches.
I have it working for a single match, as follows:
How can I adapt this to identify that there are 2 matches when filename is "N1234 and N22522 - Content" and then be able to read/access/use each of "N1234" and "N22522"?Dim nNumberPattern As String nNumberPattern = "(N[0-9]{3,}).*Content(s?).*" Dim nNumberMatches Dim nNumber As String With nNumberRegEx .Global = True .Pattern = nNumberPattern End With ' Let's find the n-number that we are working with (using the file's name) If nNumberRegEx.Test(myWorksheetObj.Parent.Name) Then Set nNumberMatches = nNumberRegEx.Execute(myWorksheetObj.Parent.Name) nNumber = nNumberMatches(0).SubMatches(0)



Reply With Quote
