Search code examples
vbaconditional-formattingms-project

Can I use Conditional Formatting in MS Project to change text color based on Task Name Text?


In MS Projects, I need to utilize VBA to conditionally format all rows with "payment" somewhere in the Task Name to have bold, red text.


Solution

  • Based on extended comments on prior answer, here is another version of a macro to format the entire row of tasks that contain 'payment' or 'go-live' in the task name.

    Sub FormatSpecificTasks()
    
        OutlineShowAllTasks
        FilterEdit Name:="temp", TaskFilter:=True, Create:=True _
            , OverwriteExisting:=True, FieldName:="Name", Test:="contains" _
            , Value:="payment", ShowInMenu:=False, ShowSummaryTasks:=False
        FilterEdit Name:="temp", TaskFilter:=True, FieldName:="" _
            , NewFieldName:="Name", Test:="contains", Value:="go-live" _
            , Operation:="Or", ShowSummaryTasks:=False
        FilterApply Name:="temp"
        SelectAll
        Font32Ex Bold:=True, Color:=255, CellColor:=RGB(255, 229, 99) 
        FilterApply Name:="all tasks"
        OrganizerDeleteItem Type:=pjFilters, FileName:=ActiveProject.Name, Name:="temp"
                
    End Sub