Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Color a part of a cell...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Color a part of a cell...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Color a part of a cell...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Color a part of a cell...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Color a part of a cell...

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
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 cell background color as part of the If statement? Jim H Excel Worksheet Functions 2 September 23rd 09 11:58 PM
Search/Match/Find ANY part of string to ANY part of Cell Value TWhizTom Excel Worksheet Functions 0 July 21st 08 08:16 PM
Change font color as part of if/then tina Excel Discussion (Misc queries) 17 February 1st 08 12:32 AM
format color of text in part of a cell b4nature Excel Discussion (Misc queries) 3 January 4th 07 05:09 PM
can I use the 'fill color' as part of a formula scottnoidea Excel Discussion (Misc queries) 1 June 29th 05 12:13 PM


All times are GMT +1. The time now is 01:37 AM.

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

About Us

"It's about Microsoft Excel"