Forum Discussion
Mino_DC
Sep 15, 2022Copper Contributor
Project Pro 2021 - Add column with total resources number
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.
- 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
3 Replies
Sort By
- John-projectSilver ContributorMino_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- Mino_DCCopper Contributor
HiJohn-project thanks for your reply.
With this macro I not obtain that I would like.
Based on your description, I found this article:
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 SubI added a Number1 column in Gantt view and next run macro.
This Macro works for me....
Thanks
- John-projectSilver ContributorMino_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