VBA Macro for MS Project (Color Coded WBS)

Anonymous
2022-12-13T12:33:13+00:00

Hi,

Can someone help me with a code for color my WBS Font in MS Project similar to Primavera P6?

WBS Level 0-10

Regards

Fredrik

Microsoft 365 and Office | Project | For education | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. John Project 49,695 Reputation points Volunteer Moderator
    2023-01-06T16:13:20+00:00

    Fredrik,

    Here's the updated macro and what it produces.

    Sub HighlightSummaries_P6()
    'Summary line color emulation P6 > Project
    'macro written by John-Project 12/21/22
    ' Changed color sequence so first summary level is Project Summary Task 1/4/23
    Dim i As Integer
    ActiveProject.DisplayProjectSummaryTask = True
    SelectAll
    EditClearFormats
    'set colors for Project Summary Task
    SelectRow Row:=0
    Font32Ex Color:=16777215, CellColor:=11892014 'R46.G117,B181
    'Set colors for summary levels
    For i = 1 To 19
    FilterEdit Name:="OLX", Taskfilter:=True, create:=True, overwriteexisting:=True, _
    FieldName:="summary", test:="equals", Value:="yes", ShowInMenu:=False
    FilterEdit Name:="OLX", Taskfilter:=True, Operation:="and", _
    NewFieldName:="outline level", test:="equals", Value:=CStr(i)
    FilterApply Name:="OLX"
    SelectAll
    If ActiveSelection > 0 Then
    'Note: Font32EX does not work with hex values
    If i = 1 Then Font32Ex CellColor:=14062212 'R132,B146,B214
    If i = 2 Then Font32Ex CellColor:=16354179 'R131,G139,B249
    If i = 3 Then Font32Ex CellColor:=16776960 'R0,G255,B255
    If i = 4 Then Font32Ex CellColor:=15058378 'R202.G197,B229
    If i = 5 Then Font32Ex CellColor:=16119719 'R167,G247,B245
    If i = 6 Then Font32Ex CellColor:=15048173 'R237,G157,B229
    If i = 7 Then Font32Ex CellColor:=10223101 'R253,G253,B155
    If i = 8 Then Font32Ex Color:=16777215, CellColor:=0 'R0,G0,B0
    If i = 9 Then Font32Ex CellColor:=14211288 'R216,G216,B216
    If i = 10 Then Font32Ex CellColor:=4690227 'R51,G145,B71
    If i = 11 Then Font32Ex Color:=16777215, CellColor:=16260866 'R22,G22,B250
    If i = 12 Then Font32Ex Color:=16777215, CellColor:=3497611 'R127,G84,B49
    If i = 13 Then Font32Ex Color:=16777215, CellColor:=10027161 'R153,G0,B153
    If i = 14 Then Font32Ex Color:=16777215, CellColor:=39423 'R255,G153,B0
    If i = 15 Then Font32Ex Color:=16777215, CellColor:=12033691 'R163,G163,B193
    If i = 16 Then Font32Ex Color:=16777215, CellColor:=42152 'R168,G164,B0
    If i = 17 Then Font32Ex Color:=16777215, CellColor:=9211036 'R156,G140,B140
    If i = 18 Then Font32Ex Color:=16777215, CellColor:=8689730 'R66,G153,B132
    If i = 19 Then Font32Ex Color:=16777215, CellColor:=11701388 'R140,G140,B178
    Else
    Exit For
    End If
    Next i
    FilterApply Name:="all tasks"
    End Sub

    John

    5 people found this answer helpful.
    0 comments No comments

22 additional answers

Sort by: Most helpful
  1. John Project 49,695 Reputation points Volunteer Moderator
    2023-01-20T21:00:48+00:00

    MEM_2022,

    Thanks for the feedback.

    John

    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more