Highlight words in cells with VBA.
- 0 0
-
shares
Ever wanted to highlight words within text similar to how most web-browsers will now highlight?
Now you can do the same in excel. Note that this only works on static text, and not on text generated by formulas.
Here's an example of it in action , some generic text - imagine you had to highlight every instance of the word 'fox' in the below range, it'd be pretty labour intensive right?
Not any more, assigned to a button or within another sub, it's easy to make all your foxes red :
Included in the sub are options to set colour by RGB, and case sensitivity, (you may not want to highlight uppercase , or only title case etc. ).
It will also find words within words , like so :
to
Usage - here the user is propted to provide the word, in this example it's set to case-insensitive ,and all words are highlighted a medium burgundy colour.
This example uses a ribbon control, but could also be applied to a button/shape in a workbook instead.
Full code.
As always, it should be mentioned with anything involving looping through ranges, beware of selecting an entire workbook by mistake..