How to calculate the number of resources assigned to a task

E

Elena Osipova

Hi,

we need to create a report where the number of resources assigned to a task
should be included together with other information about tasks. How can we do
this?
It seems that there are no standard field for number of resources assigned
to a task.....

Thanks,
Elena
 
J

John

Elena Osipova said:
Hi,

we need to create a report where the number of resources assigned to a task
should be included together with other information about tasks. How can we do
this?
It seems that there are no standard field for number of resources assigned
to a task.....

Thanks,
Elena

Elena,
Since you have posted in the developer newsgroup, I'll assume you want a
VBA solution. The Count Property of the Assignments object for any given
task will give you that value. It can then be dumped into a spare field
and included in whatever report you want. For example, the following
code puts the count into the Text1 field.

Sub Task_Res_Count()
Dim t As Task
For Each t In activeproject.Tasks
If Not t Is Nothing Then
t.Text1 = t.Assignments.count
End If
Next t
End Sub

By the way, if you were not looking for a VBA solution, I'm afraid it is
your only option because there is no specific field you can access to
get the number of resources assigned to a task.

John
Project MVP
 
E

Elena Osipova

Thanks a lot, John!

John said:
Elena,
Since you have posted in the developer newsgroup, I'll assume you want a
VBA solution. The Count Property of the Assignments object for any given
task will give you that value. It can then be dumped into a spare field
and included in whatever report you want. For example, the following
code puts the count into the Text1 field.

Sub Task_Res_Count()
Dim t As Task
For Each t In activeproject.Tasks
If Not t Is Nothing Then
t.Text1 = t.Assignments.count
End If
Next t
End Sub

By the way, if you were not looking for a VBA solution, I'm afraid it is
your only option because there is no specific field you can access to
get the number of resources assigned to a task.

John
Project MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top