Take the 2-minute tour ×
Project Management Stack Exchange is a question and answer site for project managers. It's 100% free, no registration required.

In Project 2010, is it possible to conditionally format a bar style/color based on the value of a custom field for a given task?

I see a pretty complicated workaround to accomplish this with Project 2007 here: http://blogs.catapultsystems.com/epm/archive/2009/07/23/formatting-the-gantt-chart-in-ms-project-2007.aspx, but it would be great if there is an easier way to do this in 2010.

Edit: At Perry's request, adding more information about what I am specifically trying to do.

I have a project that has tasks carried out in parallel by different teams. I have added a custom "Department" field that allows me to specify that a given task belongs to Department Foo, Department Bar, or Department Schmucatelli.

Although I can create views to filter or group the tasks by department, I would like Project to actually color-code my Gantt chart tasks Red (if they belong to Department Foo), Green (if they belong to Department Bar), or Purple (if they belong to department Schmucatelli).

I can do this manually by filtering by department, selecting all, and formatting the bars (once for each department), but I would like this to happen automatically depending on what department I select for a given task.

share|improve this question
2  
I don't have an answer for you. I've tweeted it out, but you might want to put a lot more detail in the question. With detail, if someone is interested they can play around with the problem and find you an answer. –  Perry Wilson May 15 '11 at 21:17
    
+1 good guidance, Perry. –  Mark Phillips May 15 '11 at 21:45
1  
Additional detail added :) –  Sean Earp May 15 '11 at 23:41
    
Wouldn't it be a question for superuser.com/questions/tagged/microsoft-project, as it's basically asking about a tool functionality rather than usability? I understand that it MIGHT get more answers @ PMSE as we might have more MS-Project users here, but still... –  Tiago Cardoso Nov 7 '12 at 15:05

3 Answers 3

This seems to answer your question (without the need for VB)

http://www.pmconnection.com/modules.php?name=News&file=article&sid=24

I don't have Project 2010 to verify, but the solution shown makes sense and seems to do what you want(??)

share|improve this answer
    
+1. Tested in Project 2010 and works like a charm. –  OrenD May 24 '11 at 20:34
    
Awesome! If you like the answer, you might "mark it as correct" (unless there is a better answer that comes up! :-) –  Al Biglan May 25 '11 at 1:51

I like the VBA solution above, but it's going to be slooow for large projects. Using a combination of Custom Flag Fields and Custom Bar Styles is the traditional way to do this. A tutorial for doing this is shown here.

Hope it helps.

share|improve this answer

Quick and dirty (what below is just a simple first try) VBA approach could be something like:

Sub ColorBars()
' Colors bars according to the value of Text1 field
' Written on Mon 23/05/11 by Bartlomiej Garbacz
  Dim ts As tasks
  Dim t As task
  Dim color

  Set ts = ActiveProject.tasks

  For Each t In ts
    If Not t Is Nothing Then
      If Not t.Summary Then
      ' Excluding summary tasks
        Select Case t.Text1
          Case "Team1"
            color = ColorConstants.vbRed
          Case "Team2"
            color = ColorConstants.vbGreen
          Case "Team3"
            color = ColorConstants.vbBlue
          Case Else
            color = ColorConstants.vbBlack
        End Select

        GanttBarFormatEx TaskID:=t.ID, GanttStyle:=1, StartShape:=0, StartType:=0, StartColor:=0, MiddleShape:=1, MiddlePattern:=1, MiddleColor:=color
      End If
    End If
  Next t
End Sub

And when you define a shortcut key for your macro, you can have 'almost automatic' update of your schedule.

To gain access to VBA remember to Customize the Ribbon in your MS Project 2010 Options and tick the Developer tab.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.