Link to home
Start Free TrialLog in
Avatar of Keith Blanco
Keith Blanco

asked on

In MS Project change the color of the text for an entire row based on what is indicated in the "Status" field

I am looking to change the color of the text for an entire row based on what is indicated in the "Status" field.  

I have searched other forums and have found solutions that are close, but nothing that really does what I am looking for.  I am aware of the highlight feature and of the conditional formatting, but I can't get them to do what I need. I wrote some VB code to do this exact thing about 5 years ago, but I am a novice, it took me about 5 days to write the very basic code, and then i lost it when I left my last job. :-(

So, I am looking to just have some VB that will do the following:
If Status = "Late" then color the text in the row to "RED"
If Status = "On Schedule" then color the text in the row to "GREEN"
If Status = "Future Task" then color the text in the row to "BLACK"
If Status = "Complete" then color the text in the row to "GRAY"

I would love to get advanced and have something like the following:
If Status = "On Schedule",  AND   % complete is < 85%,  AND   "Finish Date" is < 5 days in future,  then color the text in the row "ORANGE"

Any help is appreciated !!!
Avatar of Anastasia D. Gavanas
Anastasia D. Gavanas
Flag of Greece image

Use a Macro like and substitute OutlineLevel with Status
Sorry don't have MS Project right now to try
Sub ColorFormatOL()
Dim t As Task
Dim i As Integer

i = 1
For Each t In ActiveProject.Tasks
       SelectRow row:=i, rowrelative:=False
       Select Case t.OutlineLevel
           Case 1
           Font32Ex CellColor:=&HB37F15
           Case 2
           Font32Ex CellColor:=&HD6982E
           Case 3
           Font32Ex CellColor:=&HF6BE41
           Case 4
           Font32Ex CellColor:=&HF7D577
       End Select

i = i + 1
Next t
End Sub

Open in new window


You can also see a detailed example here for conditional formatting in MS Project
https://social.msdn.microsoft.com/Forums/office/en-US/e2fd5a05-8803-4d66-a201-ab0f40cbdde6/custum-field-formula?forum=projectprofessional2010general
Avatar of Keith Blanco
Keith Blanco

ASKER

Thanks.  I'll give that a shot this afternoon.
Ok.  I just ran this.   thanks, for putting this together.   I have a couple of questions.

1.) the coloring that it does colors the row, or highlights the row.  is there a way to just change the color of the text?

2.) I cannot really see the difference in the color of the rows.  they seem to all be blue.  a few are a different shade of blue, but i do not see a differentiator between the rows (different colors, yet they have the same status, same due date, etc.)
this code looks like it changes based on "outline Level."   I need it to change based on the words in the column titled "Status."

Any idea what i use to identify that column?
ASKER CERTIFIED SOLUTION
Avatar of Professor J
Professor J

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
great work Professor JJ...sorry for not responding Keith, but there is probably a time difference (it is 10am here now)...What JJ wrote should work out great.
thanks xtermie.
THank you.   Works for me.   Thanks for your time and work here.  (you saved me about a week of my life :-)  

I want to be respectful of your time - i am willing to make a donation or pay for a gig or something...

Key notes for anyone using this are:

You must Expand all lines prior to running this, or it will not run properly (i.e. if any subtasks are grouped and hidden, then it will throw off all coloring for the remainder of the tasks.)   So if you had the project plan with subtasks expanded and contracted a certain way for ease of reading, you will need to perform that expansion and reconfiguration every time.
@Keith-Blanco

You are most welcome. Please don't worry about donation gig. It didn't take more than few minutes of my evening when I was enjoying my tea and typing the code. What matters is that code works for you and that makes me happy that I was able to help.

Cheers.
Answer provided and accepted by OP