Color Part of a Text in a Cell Without Using VBA

DrDebit

Board Regular
Joined
May 20, 2013
Messages
123
Office Version
  1. 365
Platform
  1. Windows
Is there a way to color a word every time it appears in a cell...just the word?

For example, the word is "and." If the words: Andy, candy, fandom, were in separate cells, they would appear as Andy, candy, and fandom. Instead of bolding those letters, they would be colored red. Is there a way to do this without using VBA?

Thank you!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
.how about with VBA?
Suppose you want to check all cells in column A ..
(Test with a copy of your data)
VBA Code:
Sub ColourLetters()
  Dim c As Range
  Dim s As String
  Dim pos As Long, Lngth As Long
  
  Const myLetters As String = "and"
  
  Lngth = Len(myLetters)
  For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp))
    s = c.Text
    Do
      pos = InStr(pos + 1, s, myLetters, vbTextCompare)
      If pos > 0 Then c.Characters(pos, Lngth).Font.Color = vbRed
    Loop Until pos = 0
  Next c
End Sub
 
Upvote 0
This is great. How did you become so proficient at VBA?

Thank you!
 
Upvote 0
This is great. How did you become so proficient at VBA?

Thank you!
You're welcome. Glad it worked for you. :)

Hanging around this forum too much and lots of (often failed) practice. ;)
 
Upvote 0

Forum statistics

Threads
1,214,659
Messages
6,120,786
Members
448,992
Latest member
prabhuk279

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