Problem with iterating through assignments

P

Puneet Murgai

Hello,
I will appreciate any help in the following matter.

In Microsoft Project (VBScript) I am trying to iterate through task
assignments. There is only one resource assigned (Units = 1) to the
task but it loops twice bringing up the same resource again. The code
is as follows:

For Each RAssignment In Child.Assignments
UnitsToAdd = (Child.Duration / Max_Length) * RAssignment.Units
ResourcePresent = False
For Each SAssignment In SelectedTask.Assignments
If StrComp(RAssignment.ResourceName, SAssignment.ResourceName)_
= 0 Then
SAssignment.Units = SAssignment.Units + UnitsToAdd
ResourcePresent = True
Exit For
End If
Next
If Not ResourcePresent Then
SelectedTask.Assignments.Add _
Resourceid:=RAssignment.resourceid,Units:=UnitsToAdd
End If

Next

Thanks
Puneet
 
Top