VBA to colour all text blue including and after specific word.

garypea123

Board Regular
Joined
Mar 16, 2020
Messages
221
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am looking for a VBA macro which search in column E, and search for the word GMP, and format this work, and all text after it as blue.

Thanks,
Gary
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Is col E hard values or formulae?
 
Upvote 0
Try this with a copy of your workbook

VBA Code:
Sub GMP()
  Dim rFound As Range
  Dim FirstAddr As String
  
  Set rFound = Columns("E").Find(What:="*GMP*", MatchCase:=True)
  If Not rFound Is Nothing Then
    FirstAddr = rFound.Address
    Do
      rFound.Characters(InStr(1, rFound.Value, "GMP", vbBinaryCompare), Len(rFound.Value)).Font.Color = vbBlue
      Set rFound = Columns("E").Find(What:="*GMP*", After:=rFound, MatchCase:=True)
    Loop Until rFound.Address = FirstAddr
  End If
End Sub
 
Upvote 0
Solution
In that case try Peter's code.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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