#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
Hi! I didn't test it but hopefully it will work:
Code:
.text = " [0-9] " & Split(StrFndB, ",")(i) Code:
.text = "<[0-9] " & Split(StrFndB, ",")(i) |
#3
|
|||
|
|||
VBA highlight if value less than 10
Hi Vivka, the second option seems to work which I changed to accommodate non breaking spaces also. Many thanks for responding.
Code:
.text = "<[0-9][ ^s]" & Split(StrFndB, ",")(i) |
#4
|
|||
|
|||
You are welcome,Shelley Lou!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
highlight bar | freeriding | Project | 0 | 12-07-2018 05:25 AM |
I do not Want Highlight to Print | LauraLRussell | Word | 4 | 02-07-2014 07:03 AM |
VBA to highlight words if used too much | aolszewski | Word VBA | 3 | 11-23-2013 02:07 AM |
Highlight Document | Jodib | PowerPoint | 1 | 10-14-2011 07:25 AM |
find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |