View Single Post
 
Old 02-27-2024, 09:48 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Dec 2020
Posts: 171
Shelley Lou is on a distinguished road
Default VBA highlight if value less than 10

Hi, I've searched the Forum but can't find what I'm looking for - I'm trying to add a less than value to the code below so that it only highlight digits 1 to 9 as single digits e.g. 1 day or 9 years and not 10 days or 100 years. I've tried several ways of inserting <10 but nothing seems to be working. Can anyone help. Thanks

Code:
StrFndB = "[Mm]inute,[Hh]our,[Dd]ay,[Ww]eek,[Mm]onth,[Yy]ear,[Ww]orking,[Bb]usiness" 'highlight numbers before these words
For i = 0 To UBound(Split(StrFndB, ","))
          With .Duplicate
            With .Find
              .ClearFormatting
              .Replacement.ClearFormatting
              .Forward = True
              .Wrap = wdFindStop
              .MatchWildcards = True
              .text = "[0-9]{1,}[ ^s]" & Split(StrFndB, ",")(i)
            End With
            Do While .Find.Execute
              .MoveEnd wdWord, -1
              .End = .End - 1
              .HighlightColorIndex = wdBrightGreen
              .Collapse wdCollapseEnd
            Loop
          End With
        Next
Reply With Quote