Results 1 to 6 of 6

Change font colour of certain words on sheet

Threaded View

  1. #1
    Registered User
    Join Date
    01-21-2020
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    3

    Change font colour of certain words on sheet

    I'm trying to change the colour of a few words on my sheet to red. A quick search online finds this:

    
    Public Sub ChgTxtColor()
        Set myRange = Range("A1:A100")  'The Range that contains the substring you want to change color
        substr = "delete"   'The text you want to change color
        txtColor = 3   'The ColorIndex which repsents the color you want to change
        
        For Each myString In myRange
            lenstr = Len(myString)
            lensubstr = Len(substr)
            For i = 1 To lenstr
                tempString = Mid(myString, i, lensubstr)
                If tempString = substr Then
                    myString.Characters(Start:=i, Length:=lensubstr).Font.ColorIndex = txtColor
                End If
            Next i
        Next myString
    End Sub
    However, this will only change the colour of one word. Is there a way of modifying this so I can change the colour of multiple words to red?
    Last edited by Tyrannis; 01-22-2020 at 06:25 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Change font colour Entire sheet or workbook
    By mattydboom1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-29-2019, 05:02 PM
  2. [SOLVED] change of font colour or background colour vba
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-22-2014, 08:20 PM
  3. Replies: 4
    Last Post: 09-16-2013, 04:23 PM
  4. Delete all words in a particular font colour
    By paulhg2 in forum Excel General
    Replies: 5
    Last Post: 11-29-2012, 10:34 AM
  5. Font Colour Change
    By yuzi in forum Excel General
    Replies: 5
    Last Post: 03-30-2009, 11:27 AM
  6. Change Event to change Font to bold and colour Index
    By Wskip49 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-21-2008, 02:38 PM
  7. Change font colour
    By Altec101 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-30-2006, 03:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1