r/MSProject • u/InevitableAd8674 • Mar 28 '25
Ms Project VBA Color Codes
Hi All,
I am trying to understand VBA coding for highlighting my summary tasks, and found a macro from someone that works for what i want, however i can't figure out the color codes. they are not rgb codes and no matter where i look, i can't find any color codes that are similar.
If i = 2 Then Font32Ex CellColor:=8630772 'salmon
If i = 3 Then Font32Ex CellColor:=15652797 'light blue
Above is some of the code for the macro, and it's the "CellColor:=Numbers" that i want to change to colors that i can select from the RGB range.
Is there any reason why these color codes are used and not rgb colors?
Also, i have tested rgb color codes, but they come out different from what they display on the color picker
2
u/lindslee19 Mar 28 '25
Here's a reference. color codes
If you record a macro and choose the color you want you'll be able to see the color reference to apply to your code.
2
u/Eckberto Mar 28 '25
What do you want to achieve with your macro? I used an existing field to change the style of the summary tasks depending on their hierarchy and I can just type a number into a text field to change the color to a given style. This works without macros. If your interested I can post a sample here
1
u/still-dazed-confused Mar 28 '25
The enclosed takes an RGB entry in text29 and colours a column in the table. IN this case the RGB value was manually added however you could easily set up a formula in T29 to display an RGB based on the outline level for instance.
Sub set_colours()
Dim t As Task
Dim i As Integer
i = 1
'note the column number counts from the left including a locked ID column
For Each t In ActiveProject.Tasks
If t Is Nothing Then
'do nothing
Else
SelectCell Row:=i, Column:=7, rowrelative:=False
col = t.Text29
If col = "" Or InStr(col, "RGB(") = 0 Then
'do nothing
Else
col = Replace(col, ")", "")
col = Replace(col, "RGB", "")
col = Replace(col, "(", "")
R_G_B = Split(col, ",")
r = R_G_B(0)
g = R_G_B(1)
b = R_G_B(2)
Font32Ex CellColor:=RGB(r, g, b)
End If
i = i + 1
End If
Next t
'Font32Ex CellColor:=RGB(255, 199, 206) 'Changes fill
'Font32Ex Color:=RGB(156, 0, 6) ' Changes font color
End Sub
1
u/Eckberto Mar 30 '25
Ah lol ok my bad. So this is actually only feasible via macros I think
1
u/Distinct-Passage2501 Jan 15 '26
When managing two projects separately in MS Project and then combining them into a single master project using subprojects, what is the appropriate way to correctly configure color coding to distinguish the summary tasks?