If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Search Text - Change Color of Text

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-05, 08:46
Casper_1 Casper_1 is offline
Registered User
 
Join Date: Jul 2005
Posts: 4
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
Reply With Quote
  #2 (permalink)  
Old 10-28-05, 15:36
cpod cpod is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On