Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Field Showing Work for a Resource Group

Field Showing Work for a Resource Group

Field Showing Work for a Resource Group

Hallo again,

I use the following code for calculating the total work of a resource group in a Gantt Chart field.


Public Sub GetCoreWork()
Dim Task As Task
Dim Resource As Resource
Dim CoreWork As Double
Dim Assignment As Assignment

For Each Task In ThisProject.Tasks

If Task.OutlineChildren.Count = 0 Then

With Task

CoreWork = 0

For Each Resource In Task.Resources

For Each Assignment In Task.Assignments

If ThisProject.Resources(Assignment.ResourceName).Group = "Core" Then
CoreWork = Assignment.Work
End If


Task.Number1 = CoreWork / 480


End With

End If


End Sub

Unfortunately, if there is more than one resources assign to a task (of the same resource group) the code writes only the work of one resource, not the sum of the total work of group Core (total work of all persons of group Core, assign to the specific task).

Could you please help me with this ?
Where did i go wrong ?

Thanks in advance  again !

RE: Field Showing Work for a Resource Group

I'm not sure I understand your logic.

To me, it appears you are going to each task and then, for each task, you then loop through all resources (not just those assigned to the task).

Try this code instead:

Option Explicit
Public Sub PDQBach()
Dim tsk As Task
Dim res As Resource
Dim asgn As Assignment
Dim intMinsPerDay As Integer
Dim dblCoreWork As Double

intMinsPerDay = ActiveProject.HoursPerDay * 60

For Each tsk In ActiveProject.Tasks
    If Not tsk Is Nothing Then
        If Not tsk.Summary Then
            dblCoreWork = 0
            For Each asgn In tsk.Assignments
                If UCase(asgn.Resource.Group) = "CORE" Then
                    dblCoreWork = dblCoreWork + asgn.Work
                End If
            tsk.Number1 = dblCoreWork / intMinsPerDay
        End If
    End If
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close