Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Good Day,
I have a cell with this text: "1 - aaaaaaaa 2 - bbbbbbbb 3 - ccccccccc" how to color in red, just the "1-, 2- and 3-" anyone help? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use this
Range("A1").Characters(Start:=1, Length:=2).Font.ColorIndex = 3 -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Tiago" wrote in message ... Good Day, I have a cell with this text: "1 - aaaaaaaa 2 - bbbbbbbb 3 - ccccccccc" how to color in red, just the "1-, 2- and 3-" anyone help? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thkanks, it works....
"Ron de Bruin" wrote: You can use this Range("A1").Characters(Start:=1, Length:=2).Font.ColorIndex = 3 -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Tiago" wrote in message ... Good Day, I have a cell with this text: "1 - aaaaaaaa 2 - bbbbbbbb 3 - ccccccccc" how to color in red, just the "1-, 2- and 3-" anyone help? Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another way
select cell in formula-line select part u want colored and click color "Tiago" skrev: thkanks, it works.... "Ron de Bruin" wrote: You can use this Range("A1").Characters(Start:=1, Length:=2).Font.ColorIndex = 3 -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "Tiago" wrote in message ... Good Day, I have a cell with this text: "1 - aaaaaaaa 2 - bbbbbbbb 3 - ccccccccc" how to color in red, just the "1-, 2- and 3-" anyone help? Thanks |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 28 May 2007 04:23:00 -0700, Tiago
wrote: Good Day, I have a cell with this text: "1 - aaaaaaaa 2 - bbbbbbbb 3 - ccccccccc" how to color in red, just the "1-, 2- and 3-" anyone help? Thanks That can only be done if the text is an actual text string, and not the result of a function. The following will work assuming the leading number is a single digit as you have shown: ----------------------------- Option Explicit Sub ColorNum() Dim c As Range Dim str As String Dim i As Long Dim char As String Dim lRedLength As Long For Each c In Selection str = c.Text c.Font.Color = vbBlack 'or whatever the base color is For i = 1 To Len(str) char = Mid(str, i, Len(str) + 1 - i) If char Like "#*-?*" Then lRedLength = InStr(i, str, "-") - i + 1 c.Characters(i, lRedLength).Font.Color = vbRed i = i + lRedLength End If Next i Next c End Sub -------------------------------------- --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to change cell background color as part of the If statement? | Excel Worksheet Functions | |||
Search/Match/Find ANY part of string to ANY part of Cell Value | Excel Worksheet Functions | |||
Change font color as part of if/then | Excel Discussion (Misc queries) | |||
format color of text in part of a cell | Excel Discussion (Misc queries) | |||
can I use the 'fill color' as part of a formula | Excel Discussion (Misc queries) |