Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2005
    Posts
    4

    Unanswered: Search Text - Change Color of Text

    I have different airports in cells written like this: MNL/HNL/JFK/.... My code changes color of whole text in cell if code of airport is found.
    MNL/HNL/JFK/
    That's wrong.

    I need a quick solution to changes color of airport (if found) to the color Red.
    The end result would be: MNL/ HNL /JFK


    I have this code:


    If InStr(rngFind, "HNL") > 0 Then
    Set rngMerge = rngFind.MergeArea
    rngMerge.Font.ColorIndex = 3
    rngMerge.EntireRow.Copy
    With Worksheets("AU - UA")
    NextRow = Range("A65536").End(xlUp).Row + 1
    Range("A" & NextRow).Select
    .Range("a" & intRow2 + 1).PasteSpecial
    .Range("a" & intRow2 + 1) = "HNL"
    End With
    intRow2 = intRow2 + rngMerge.Rows.Count
    End If

  2. #2
    Join Date
    Feb 2002
    Posts
    29
    The Characters method allows you to set formating for individual elements in a string:

    intFind = InStr(rngFind, "HNL")
    If intFind > 0 Then
    Set rngMerge = rngFind.MergeArea
    rngMerge.Characters(intFind, 3).Font.ColorIndex = 3
    rngMerge.EntireRow.Copy
    With Worksheets("AU - UA")
    NextRow = Range("A65536").End(xlUp).Row + 1
    Range("A" & NextRow).Select
    .Range("a" & intRow2 + 1).PasteSpecial
    .Range("a" & intRow2 + 1) = "HNL"
    End With
    intRow2 = intRow2 + rngMerge.Rows.Count
    End If

Posting Permissions

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