4

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.

5
  • 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. May 15, 2011 at 21:17
  • 1
    Additional detail added :)
    – Sean Earp
    May 15, 2011 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, 2012 at 15:05
  • Will the VBA solution above work with the calendar view? If so, how? Thanks!
    – user16483
    Mar 5, 2015 at 15:18
  • This does not look like an answer to the question. I suggest that it may be more appropriate to put this as a comment to the original question, rather than posting it as an answer.
    – Iain9688
    Mar 5, 2015 at 18:13

3 Answers 3

5

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(??)

2
  • +1. Tested in Project 2010 and works like a charm.
    – OrenD
    May 24, 2011 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, 2011 at 1:51
2

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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