Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2024, 09:48 AM
Shelley Lou Shelley Lou is offline VBA highlight if value less than 10 Windows 10 VBA highlight if value less than 10 Office 2016
Competent Performer
VBA highlight if value less than 10
 
Join Date: Dec 2020
Posts: 170
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
  #2  
Old 02-27-2024, 01:47 PM
vivka vivka is offline VBA highlight if value less than 10 Windows 7 64bit VBA highlight if value less than 10 Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

Hi! I didn't test it but hopefully it will work:
Code:
.text = " [0-9] " & Split(StrFndB, ",")(i)
or

Code:
.text = "<[0-9] " & Split(StrFndB, ",")(i)
Reply With Quote
  #3  
Old 02-28-2024, 01:33 AM
Shelley Lou Shelley Lou is offline VBA highlight if value less than 10 Windows 10 VBA highlight if value less than 10 Office 2016
Competent Performer
VBA highlight if value less than 10
 
Join Date: Dec 2020
Posts: 170
Shelley Lou is on a distinguished road
Default 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)
Reply With Quote
  #4  
Old 02-28-2024, 05:34 AM
vivka vivka is offline VBA highlight if value less than 10 Windows 7 64bit VBA highlight if value less than 10 Office 2016
Competent Performer
 
Join Date: Jul 2023
Posts: 227
vivka is on a distinguished road
Default

You are welcome,Shelley Lou!
Reply With Quote
Reply



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 highlight if value less than 10 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:40 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft