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.
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. 🙁
Have you created the bar for the flag field in Bar Styles Jane?
Which version of excel is this. am using Excel2013 and dont see this option?
never mind, got it.
Koert Smidt says
Hi Alan, when I am using this technique I can’t see my progress indicator in the Bar, it doesn’t shows the progress of the task. Do you have a solution?
Thanks in advance,
The progress indicator is its own bar. Click on Format and then Format Bar Styles. Check that your new coloured bars allow the progress t be shown. Also double check the Progress bar style to make the colour visible.
Rachel Yoxall says
Hi, Thanks for the tutorial, very helpful. However I am having the same issue as Jane above “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 tried [Resource Name] = “John Daly” , but it would not register for tasks assigned to John Daly.” Nor can i update them manually from the Gantt Chart. I have also created the bar style, which appears to be fine but is still not carrying forward.
Ahsan Khalid says
Thank you for the tutorial. But it is not working for me.
Alan Murray says
You’re welcome. That’s a shame. I’d check the steps.
Katie B says
Thanks for this – it worked perfectly. I don’t understand why the Microsoft support page is so useless and doesn’t even mention this as an option. So glad for people like you.
The only extra thing I did was the take the end caps off the Manually Scheduled task format, as it kept making them green regardless of the formatting I gave each flag.
Alan Murray says
Thank you, Katie.
How do i do this for status? as in i have four of them; complete, on schedule, behind schedule and blocked. so i want a colour for each of the ? any help guys