Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to change text color in a cell "comment" in Office 2007? | Excel Worksheet Functions | |||
Excel: Changing "numeric $" to "text $" in a different cell. | Excel Worksheet Functions | |||
Changing the color of the "comment" triangle | Excel Discussion (Misc queries) | |||
Insert "-" in text "1234567890" to have a output like this"123-456-7890" | Excel Discussion (Misc queries) | |||
Changing "returned" values from "0" to "blank" | Excel Worksheet Functions |