Highlight Text

Welsh Mark3

Board Regular
Joined
Apr 7, 2014
Messages
164
Office Version
  1. 365
I have a column of notes - lets say this is column A. I want to highlight just part of the the text. In this case it just "#addingvalue"

I can use the Conditional formatting function but to my knowledge it highlights the entire cell, I just want to highlight of change color of text just for the phase shown above.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Are the values hard values, or the result of a formula?
 
Upvote 0
In that case try
Code:
Sub WelshMark3()
   Dim Cl As Range
   Dim x As Long
   
   For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
      x = InStr(1, Cl.Value, "#addingvalue", vbTextCompare)
      If x > 0 Then Cl.Characters(x, 12).Font.Color = vbRed
   Next Cl
End Sub
 
Upvote 0
re: Sub WelshMark3()

In the code what is the relevance of "
WelshMark3", is this what the sheet or file name should be called?

 
Upvote 0
No it's just the name of the macro, you can change it to something more meaningful.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
This has actually worked better than I expected, If i wanted to use this code and change the 'Phrase' for the same range Would I simply run as an additional macro? I think I've confident in amending the code.
Is it possible to run this on multiple phrase in one code? or an additional macro?
Changing the color of the font - Would I simply amend " If x > 0 Then Cl.Characters(x, 12).Font.Color = vbRed" to for example " If x > 0 Then Cl.Characters(x, 12).Font.Color = vbYellow"

 
Upvote 0
Changing the color of the font - Would I simply amend " If x > 0 Then Cl.Characters(x, 12).Font.Color = vbRed" to for example " If x > 0 Then Cl.Characters(x, 12).Font.Color = vbYellow"
Yes, that's right :)
As for the string, will you only have one of the strings in an individual cell or could you have more?
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top