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.
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.
- From the Gantt Chart, click the Format tab on the Ribbon and then the Custom Fields button in the Columns group.
- Select Flag from the list of data types in the top right corner of the Custom Fields dialog box.
- With Flag1 selected in the list, click the Rename button and assign a meaningful name to the field.
- 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.
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.
- Click Ok to the warning below. It is just letting you know that Project will now calculate this field. This is good.
- Repeat this for each coloured bar you will need. In this example, I will create one more for Team 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.
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.
- From the Gantt Chart, click the Format tab on the Ribbon, the Format button and then Bar Styles.
- Scroll to the bottom of the list of bar styles in the top half of the dialog box.
- Click in the Name cell in the next empty row and enter a name for the bar.
- Click in the Show For … Tasks cell and select the flag field from the list that you want to link the bar to.
- 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.
- Repeat these steps for each bar style that you need.
- Click Ok.
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.
- Click the View tab on the Ribbon
- Click Other Views and then Save View.
- Enter a name for the new view and click Ok.
- Your new Gantt Chart view will now appear as an option when changing view.