November 15, 2020
I am trying to add a 0 before two digits in a title across hundreds of rows. I am trying to use VBA regex. There is something I am not understanding about regex. This is what a title looks like:
The BigBook, Vol. 1, No. 1 <== The end result should look like ==> The BigBook, Vol. 01, No. 01 (there are 1 - 9 Vol. nums and No. nums)
Here is my test code so far.
Dim stringOne As String
Dim regexOne As Object
Set regexOne = New RegExp
regexOne.Pattern = "Vol. [0-9], No. [0-9]"
regexOne.Global = True
stringOne = "The BigBook, Vol. 1, No. 1"
Debug.Print regexOne.replace(stringOne, "Vol. 0[0-9], No. 0[0-9]")
I think I'm close...but can't seem to figure this out. Any help would be appreciated. Thanks.