Automatically Format the Colour of Task Bars in Gantt Chart

3 Flares 3 Flares ×

I am often asked in Microsoft Project courses how to automatically change the colour of the task bars in a Gantt Chart dependent upon the tasks resource, or location.

The truth is that this can be a complicated process, but once it is set up it is good to go. Save your view and you will never have to worry about it again.

In this example I plan to format the colour of the task bars by the resource group. I want the colour of the bars to indicate the team that are working on that task. When someone assigns a resource to a task, Project will automatically format the task bar colour in the Gantt Chart.

Gantt Chart with Resource Group column

Create a Custom Flag Field

MS Project allows you to create your own bar styles based on flag fields. My first step is to create a custom field using the flag data type.

Flag fields contain Yes or No. I will use a formula so Project automatically assigns yes to the flag dependent upon the resource group. I will need a flag for each team in the project.

  1. From the Gantt Chart, click the Format tab on the Ribbon and then the Custom Fields button in the Columns group.
  2. Select Flag from the list of data types in the top right corner of the Custom Fields dialog box.

Create a flag custom field

  1. With Flag1 selected in the list, click the Rename button and assign a meaningful name to the field.

Rename the flag field

  1. Click the Formula button and enter the required formula. The formula below ensures that the flag is set to yes if the Resource Group field is equal to Team 1.

Using a formula in an MS Project custom field

This formula is what makes the automatic formatting tick. Enter any formula that evaluates to TRUE or FALSE to get the formatting you need.

For example you could format the task bars to show the task is running late, or if it is over budget, or has a deadline.

  1. Click Ok to the warning below. It is just letting you know that Project will now calculate this field. This is good.

Custom field with formula warning message

  1. Repeat this for each coloured bar you will need. In this example, I will create one more for Team 2.
  2. Click Ok to save and close the Custom Fields dialog box.

The image below shows the two flag columns inserted into the table. Each column (Team 1 and Team 2) automatically display yes dependent on the value of the Resource Group field.

The columns do not need to be inserted into the table. This is only done here to demonstrate that they work.

Flag columns dependent upon resource group

Create a New Bar Style

Now I need to create a new bar style for each team. The bars will be related to the flag fields. If the flag field contains yes, then the bar will automatically change colour.

  1. From the Gantt Chart, click the Format tab on the Ribbon, the Format button and then Bar Styles.

Bar Styles dialog box

  1. Scroll to the bottom of the list of bar styles in the top half of the dialog box.
  2. Click in the Name cell in the next empty row and enter a name for the bar.
  3. Click in the Show For … Tasks cell and select the flag field from the list that you want to link the bar to.
  4. In the bottom half of the dialog box, choose the formatting that you want to apply to the bar e.g. change the middle colour option to change the colour of the bar.

Create new bar styles based on flag fields

  1. Repeat these steps for each bar style that you need.
  2. Click Ok.

Automatically change task bar colour dependent upon resource group field

Watch the Video

Saving the Current View

For long term consistent use of MS Project it may be worth considering saving this view and/or saving the file as a Project template.

This will ensure that you do not need to repeat these steps every time you start a new project. By saving a view, it also means that you can create different views for different needs.

You could have a Gantt Chart that illustrates resource assignments, another for identifying tasks running behind schedule, another that shows tasks running over budget and so on.

  1. Click the View tab on the Ribbon
  2. Click Other Views and then Save View.
  3. Enter a name for the new view and click Ok.

Saving new resource group gantt chart

  1. Your new Gantt Chart view will now appear as an option when changing view.

Applying the new gantt chart view

2 thoughts on “Automatically Format the Colour of Task Bars in Gantt Chart

  1. I tried to do this by naming the the flags with people’s names. Although the people showed up under the list of the task’s resources and the custom fields were listed on the tab corresponding tab for the task, none of the fields were checked. All 20 colns have lists of no, no, no. I updated them manually and the colors showed up as advertised, but I don’t know why it is not automatically updating. I tried [Resource Name] = “John Daly” , but it would not register for tasks assigned to John Daly. 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *