Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I want to change the color of part of a string of text in a cell, not the
whole cell. I know I need a macro but am not a knowledgeable VB user. Would someone be willing to share code with me that would change the color of the word "no" to red when found within a string in a select group of cells. Hopefully what I am asking makes sense! Thank you! |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have provided an example at http://HelpExcel.com/examples
The name of the file is colorNo.xls -- http://HelpExcel.com "b4nature" wrote: I want to change the color of part of a string of text in a cell, not the whole cell. I know I need a macro but am not a knowledgeable VB user. Would someone be willing to share code with me that would change the color of the word "no" to red when found within a string in a select group of cells. Hopefully what I am asking makes sense! Thank you! |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Sub RedNose()
Set myrange = Selection For Each mycell In myrange k = InStrRev(UCase(mycell), "NO") If k 0 Then mycell.Characters(Start:=k, Length:=2).Font.ColorIndex = 3 End If Next End Sub select the range to process and run the macro from Tools | Macro | Macros best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "b4nature" wrote in message ... I want to change the color of part of a string of text in a cell, not the whole cell. I know I need a macro but am not a knowledgeable VB user. Would someone be willing to share code with me that would change the color of the word "no" to red when found within a string in a select group of cells. Hopefully what I am asking makes sense! Thank you! |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I expect you want only the isolated word "no" in red, so I have modified the
code Sub RedNose() Set myrange = Selection For Each mycell In myrange k = InStrRev(UCase(mycell), "NO") If Mid(mycell, k + 2, 1) < " " Then k = 0 If k 1 Then If Mid(mycell, k - 1, 1) < " " Then k = 0 End If If k 0 Then mycell.Characters(Start:=k, Length:=2).Font.ColorIndex = 3 End If Next End Sub -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "b4nature" wrote in message ... I want to change the color of part of a string of text in a cell, not the whole cell. I know I need a macro but am not a knowledgeable VB user. Would someone be willing to share code with me that would change the color of the word "no" to red when found within a string in a select group of cells. Hopefully what I am asking makes sense! Thank you! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy from a Cell to a text box. | Excel Worksheet Functions | |||
Extracting part of Text from one cell to another | Excel Worksheet Functions | |||
text and date format in a cell | Excel Discussion (Misc queries) | |||
Custom functions calculating time arguments Help Desperate | Excel Worksheet Functions | |||
Possible Lookup Table | Excel Worksheet Functions |