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 !!!
Keith BlancoAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

ProfessorJimJamConnect With a Mentor Commented:
i hate to sit and watch for the question to be flagged neglected.

so, here you go, i wrote this code for you.  it does not only take care of the first part, but it goes beyond to the advanced section you mentioned in your original post.

Sub ChangeFontColor()

' Solution by ProfessorJimJam. EE Quqestion 28965268
 Dim tskT As Task
 For Each tskT In ActiveProject.Tasks
     Select Case tskT.Status
      Case pjOnSchedule
             SelectRow Row:=tskT.ID, RowRelative:=False
             Font Color:=pjGreen
  If CDate(tskT.Finish) < CDate((ActiveProject.CurrentDate) + 5) And CInt(tskT.PercentComplete) < 85 Then
          SelectRow Row:=tskT.ID, RowRelative:=False
          Font32Ex Color:=49407
      End If
      Case pjComplete
             SelectRow Row:=tskT.ID, RowRelative:=False
             Font32Ex Color:=12566463
      Case pjLate
             SelectRow Row:=tskT.ID, RowRelative:=False
             Font Color:=pjRed
      Case pjFutureTask
             SelectRow Row:=tskT.ID, RowRelative:=False
             Font Color:=pjBlack
     End Select
 Next tskT

 End Sub

Open in new window

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
Keith BlancoAuthor Commented:
Thanks.  I'll give that a shot this afternoon.
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Keith BlancoAuthor Commented:
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.)
Keith BlancoAuthor Commented:
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?
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.
Keith BlancoAuthor Commented:
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.

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.

Answer provided and accepted by OP
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.