• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

adding array to a loop

Status
Not open for further replies.

jassybun

Member
this code works -but I have multiple text words that need to be red in addition to "late".

How can I add more words?

Code:
Public Sub ChgTxtColor()
Set myRange = Range("A25:A100") 'The Range that contains the substring you want to change color
substr = "late" '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
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top