TransWikia.com

MS Project Change Text Color in Row based on Status Field

Super User Asked by Cobra75007 on November 22, 2021

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 VBA 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”

One Answer

Sub CompletePercentSub()

Dim t As Task Dim i As Integer

'Iterates through the entire ms project file

i = 1 For Each t In ActiveProject.Tasks

SelectRow Row:=i, RowRelative:=False

If Not t Is Nothing Then

    Select Case t.Status
        Case 0 'Complete
            Font32Ex CellColor:=&H98FB98 'LIGHT GREEN
        Case 1 'On Schedule
            Font32Ex CellColor:=&HE0FFFF 'TAN
        Case 2 'Late
            Font32Ex CellColor:=&HC0FF& 'LIGHT RED
        Case 2 'Future Task
            Font32Ex CellColor:=&HFFFFFF 'WHITE
    End Select
End If

i = i + 1

Next t

End Sub

Answered by user760527 on November 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP