SOLVED

Project Pro 2021 - Add column with total resources number

Copper Contributor

I would like to add a column with the total number of resources in the Gantt view.
If I add 4 resources for a specific task, I would like to see in the column, the sum of the resources ... in this case, 4.

I tried this, but it didn't work:


I created 4 resources in the "Resource Sheet" and added the value 1 to the "Number 1" field and all 4 resources are in the same Group.
Next, in the Gantt view, I add the column with choice Number 1 and modified it, like so:

 
 

https://docs.microsoft.com/answers/storage/attachments/239762-image.png 




How can I do this?

Thanks all for any suggestions.

3 Replies
Mino_DC,
The reason it didn't work for you is because the Resource Number1 field is not the same as the Task Number1 field. For reference, there are also two more Number1 fields, one for Task Assignments and one for Resource Assignments.

This same question came up a while back and I wrote the macro.
John
Sub ResCountPlus()
'This macro writes the number of task assignments into Text1
' and writes the number of working days for each task into Text2
Dim t As Task
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.Assignments.Count > 0 Then
t.Text2 = t.Assignments.Count
End If
t.Text1 = Format(t.Duration / 60 / ActiveProject.HoursPerDay, "##") & " days"
End If
Next t
End Sub

Hi@John-project  thanks for your reply.

With this macro I not obtain that I would like.

Based on your description, I found this article:

https://answers.microsoft.com/en-us/msoffice/forum/all/microsoft-project-counting-total-resources-in...

 

where you have written this solution:

Sub CountWorkRes()
Dim t As Task
Dim a As Assignment
Dim i As Integer
For Each t In ActiveProject.Tasks
i = 0
If Not t Is Nothing Then
For Each a In t.Assignments
If a.ResourceType = pjResourceTypeWork Then i = i + 1
Next a
t.Number1 = i
End If
Next t
End Sub

 

I added a Number1 column in Gantt view and next run macro.

This Macro works for me....

 

Thanks

best response confirmed by Mino_DC (Copper Contributor)
Solution
Mino_DC,
You're welcome and thanks for the feedback. Obviously I wrote both macros, one counts all assignments while the other is focused on only work type resources. I'm glad you found the one that works for you.
John
1 best response

Accepted Solutions
best response confirmed by Mino_DC (Copper Contributor)
Solution
Mino_DC,
You're welcome and thanks for the feedback. Obviously I wrote both macros, one counts all assignments while the other is focused on only work type resources. I'm glad you found the one that works for you.
John

View solution in original post