Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Changing text color of certain "word" in cell

Is there a way to change the text color of a certain word in a cell?

For example, this is what cell A7 contains:
"placed on 10 years probation suspended pending passing a psychiatric
and medical evaluations and during probation is prohibited from
supervising physician assistants and effective June 15 2008 at 5:00 pm
the license is suspended for 60 days."

If the cell contains the word "suspended", I would like it to change
color to red...but only the word "suspended" and not the entire cell.

I tried searching for conditional formatting or VB but came up with
nothing. I'm not really sure the keywords to use, so maybe that's why
I'm not coming up with anything.

Is this possible? I appreciate any help I could get.


Thank you,
Sharon
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Changing text color of certain "word" in cell

On Thu, 26 Jun 2008 14:57:26 -0700 (PDT), "
wrote:

Is there a way to change the text color of a certain word in a cell?

For example, this is what cell A7 contains:
"placed on 10 years probation suspended pending passing a psychiatric
and medical evaluations and during probation is prohibited from
supervising physician assistants and effective June 15 2008 at 5:00 pm
the license is suspended for 60 days."

If the cell contains the word "suspended", I would like it to change
color to red...but only the word "suspended" and not the entire cell.

I tried searching for conditional formatting or VB but came up with
nothing. I'm not really sure the keywords to use, so maybe that's why
I'm not coming up with anything.

Is this possible? I appreciate any help I could get.


Thank you,
Sharon


You can either do it manually, by highlighting the word "suspended" and then
selecting Red for the text color, or you can do it with a VBA Macro.

To enter the macro, <alt-F11 opens the VB Editor. Ensure your project is
highlighted in the project explorer window, then select Insert/Module and paste
the code below into the window that opens.


To use this, select the cell(s) that need to be processed.

<alt-F8 opens the macro dialog box.

Then select Red and <Run

-------------------------
Option Explicit
Sub Red()
Dim c As Range
Dim r As Range
Dim sWord As String
Dim Start As Long

sWord = "suspended"

Set r = Selection

For Each c In r
With c
.Font.Color = vbBlack
Start = 1 - Len(sWord)
Do
Start = InStr(Start + Len(sWord), .Value, sWord, vbTextCompare)
If Start 0 Then
.Characters(Start, Len(sWord)).Font.Color = vbRed
End If
Loop Until Start = 0
End With
Next c
End Sub
=================================
--ron
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Changing text color of certain "word" in cell

Thanks Ron. That did the trick. I added it in my current macro and
it worked perfectly. Thanks again.
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Changing text color of certain "word" in cell

On Fri, 27 Jun 2008 08:54:26 -0700 (PDT), "
wrote:

Thanks Ron. That did the trick. I added it in my current macro and
it worked perfectly. Thanks again.


You're most welcome. Thanks for the feedback.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change text color in a cell "comment" in Office 2007? conductor Excel Worksheet Functions 1 June 2nd 07 02:50 AM
Excel: Changing "numeric $" to "text $" in a different cell. Heather_CCF Excel Worksheet Functions 1 September 5th 06 06:06 PM
Changing the color of the "comment" triangle Mike Excel Discussion (Misc queries) 6 August 21st 06 11:19 PM
Insert "-" in text "1234567890" to have a output like this"123-456-7890" Alwyn Excel Discussion (Misc queries) 3 October 25th 05 11:36 PM
Changing "returned" values from "0" to "blank" LATATC Excel Worksheet Functions 2 October 20th 05 04:41 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"