Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color text macro


Before
Projects |Dates
100101 |17-Jul-2005
100101 |19-Jul-2005
100102 |01-Apr-2005
100102 |30-Jul-2005
100102 |31-Jul-2005
100103 |29-Jul-2005
100104 |17-Jul-2005
100105 |17-Jul-2005

After
Projects |Dates
100101 |17-Jul-2005
100101 |19-Jul-2005
100102 |01-Apr-2005
100102 |30-Jul-2005
100102 |31-Jul-2005
100103 |29-Jul-2005
100104 |17-Jul-2005
100105 |17-Jul-2005

I need help to create a macro to color code the project numbers. In
this example 100101 has two projects...I would like to color the 1st
two letters of both projects red to know that there are 2 projects
with this project number when i do a filter. A second example; there
are three project 100102, I would like the first three digits red to
know that there are three projects with the same project number as this
one. etc...

Any help is appreciated.
Thx.


--
mister z
------------------------------------------------------------------------
mister z's Profile: http://www.excelforum.com/member.php...o&userid=28099
View this thread: http://www.excelforum.com/showthread...hreadid=476359

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Color text macro

If these project numbers are stored as numbers, then you can't color
individual digits. You need to store them as strings. (the code does that
if they are not already).

Sub abc()
Dim lastrow As Long, startrow As Long
Dim rng As Range, cell As Range
Dim i As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
startrow = 1
For i = 2 To lastrow + 1
If Cells(i, 1) < Cells(i - 1, 1) Then
Set rng = Range(Cells(startrow, 1), Cells(i - 1, 1))
For Each cell In rng
cell.Value = "'" & cell.Value
cell.Characters(1, rng.Count).Font.ColorIndex = 3
startrow = i
Next
End If
Next
End Sub

worked for me.




--
Regards,
Tom Ogilvy

"mister z" wrote in
message ...

Before
Projects |Dates
100101 |17-Jul-2005
100101 |19-Jul-2005
100102 |01-Apr-2005
100102 |30-Jul-2005
100102 |31-Jul-2005
100103 |29-Jul-2005
100104 |17-Jul-2005
100105 |17-Jul-2005

After
Projects |Dates
100101 |17-Jul-2005
100101 |19-Jul-2005
100102 |01-Apr-2005
100102 |30-Jul-2005
100102 |31-Jul-2005
100103 |29-Jul-2005
100104 |17-Jul-2005
100105 |17-Jul-2005

I need help to create a macro to color code the project numbers. In
this example 100101 has two projects...I would like to color the 1st
two letters of both projects red to know that there are 2 projects
with this project number when i do a filter. A second example; there
are three project 100102, I would like the first three digits red to
know that there are three projects with the same project number as this
one. etc...

Any help is appreciated.
Thx.


--
mister z
------------------------------------------------------------------------
mister z's Profile:

http://www.excelforum.com/member.php...o&userid=28099
View this thread: http://www.excelforum.com/showthread...hreadid=476359



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Color text macro


Worked like a charm. True geniusness. Thanks!


--
mister z
------------------------------------------------------------------------
mister z's Profile: http://www.excelforum.com/member.php...o&userid=28099
View this thread: http://www.excelforum.com/showthread...hreadid=476359

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
Make text color match cell color with macro? JoeSpareBedroom Excel Discussion (Misc queries) 1 June 26th 07 07:09 PM
Cond. format text color based on another's text color manxman Excel Discussion (Misc queries) 3 August 31st 06 06:27 PM
Can't format cell color/text color in Office Excel 2003 in files . albertaman Excel Discussion (Misc queries) 0 February 16th 06 03:56 AM
Color Text Macro mister z Excel Programming 1 October 14th 05 08:45 PM
Macro to change cell text color James C Excel Discussion (Misc queries) 1 August 12th 05 06:59 PM


All times are GMT +1. The time now is 02:14 PM.

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"