J
JD
Hey guys, I have another question for you. I am using this macro to
automatically assign resources to tasks, based on a number placed in the
field Number1.
Sub Automatic_Resource_Assignment()
Dim Temp1 As Long
Dim Temp2 As Long
On Error Resume Next
For Temp1 = 1 To ActiveProject.Resources.Count
For Temp2 = 1 To ActiveProject.Tasks.Count
If ActiveProject.Resources(Temp1).Number1 =
ActiveProject.Tasks(Temp2).Number1 Then
ActiveProject.Tasks(Temp2).Assignments.Add ResourceID:=Temp1
Next Temp2
Next Temp1
End Sub
It works perfectly, but it sometimes assigns a resource to a task three or
four times. This isn't a problem with the macro, it's an issue with the
data. I'm wondering if there is a way to prevent it from assigning a
resource to the same task twice, or a way to write a macro that would be run
afterward and delete the duplicates.
automatically assign resources to tasks, based on a number placed in the
field Number1.
Sub Automatic_Resource_Assignment()
Dim Temp1 As Long
Dim Temp2 As Long
On Error Resume Next
For Temp1 = 1 To ActiveProject.Resources.Count
For Temp2 = 1 To ActiveProject.Tasks.Count
If ActiveProject.Resources(Temp1).Number1 =
ActiveProject.Tasks(Temp2).Number1 Then
ActiveProject.Tasks(Temp2).Assignments.Add ResourceID:=Temp1
Next Temp2
Next Temp1
End Sub
It works perfectly, but it sometimes assigns a resource to a task three or
four times. This isn't a problem with the macro, it's an issue with the
data. I'm wondering if there is a way to prevent it from assigning a
resource to the same task twice, or a way to write a macro that would be run
afterward and delete the duplicates.