I am trying to use regEx to find dates and bold them within text in multiple cells in a range but it appears that I am not using the correct expression for bolding text using regEx. The code below is working other than the bolding function. I need regEx as I need to bold all dates in the format of yyyy-mm-dd. I know that the regEx expression below is not correct to do this but i was going to get the bolding function working before i tackled the next part.
I have checked all the other questions and they all steer away from using regEx for bolding.
Sub Bold_a_date2() Dim ws As Worksheets Dim item As Variant Dim arr As Variant arr = Worksheets("Formatted").Range("M1:M1000") Dim regEx As New RegExp regEx.Global = True regEx.Pattern = "202[0-9]" Dim text As Variant Dim mc As MatchCollection, row As Long row = 1 For Each text In arr If regEx.test(text) = True Then Set mc = regEx.Execute(text) Selection.Font.Bold = True Debug.Print text End If row = row + 1 Next text End Sub https://stackoverflow.com/questions/65929181/bold-text-using-regexp-regular-expressions January 28, 2021 at 08:00AM

没有评论:
发表评论