Task Assignment Num1 to Resource Assignment Num1 value?

Q

Quizzed again

I am trying to set the task assignment number 1 to equal the resource
assignment number 1 in MSP2007 using a macro.

Can this be done?
Thank you!
 
Q

Quizzed again

Interesting. Thank you.
In my case the data already exists in the resource usage view and I want to
transfer it to the task usage view. I am afraid that I am am not very
experienced at VBA.

How could this be modified to do that?

Sub Task_CF_To_Resource_Usage()
Dim Reso As Resource
Dim Task_As As Assignment
Dim Reso_As As Assignment
Dim Job As Task
For Each Job In ActiveProject.Tasks
If Not Job Is Nothing Then
For Each Task_As In Job.Assignments
Task_As.Text1 = Job.Text1
Set Reso = ActiveProject.Resources(Task_As.ResourceID)
For Each Reso_As In Reso.Assignments
If Reso_As.TaskID = Job.ID Then
Reso_As.Text1 = Task_As.Text1
End If 'TaskID
Next Reso_As
Next Task_As
End If 'Nothing
Next Job
End Sub
 
Q

Quizzed again

Actually I think I am pretty close using the other macro at the link you gave
me. I modified it to look like this but I am getting a run-time error 91:
object variable or with block variable not set. Here is what I have:

Sub Resource_CF_To_Task_Usage()
Dim Reso As Resource
Dim Task_As As Assignment
Dim Reso_As As Assignment
Dim Job As Task
For Each Reso In ActiveProject.Resources
If Not Reso Is Nothing Then
For Each Reso_As In Reso.Assignments
Task_As.Number1 = Reso_As.Number1 - This is what I changed and then removed
the following lines

'Set Job = ActiveProject.Tasks(Reso_As.TaskID)
''For Each Task_As In Job.Assignments
''If Task_As.ResourceID = Reso.ID Then
''Task_As.Text2 = Reso_As.Text2
'End If 'TaskID
'Next Task_As

Next Reso_As
End If 'Nothing
Next Reso
End Sub

Can you tell how far off the mark I am?
I really appreciate your time and help!
 
Q

Quizzed again

Jan you are terrific! Here is what I am using at it works great. I really
only had to modify one line to set Task_As.Number1 = Reso_As.Number1 and then
commented out one line as seen below. Thank you for pointing me in the
correct direction!

Sub Resource_CF_To_Task_Usage()
Dim Reso As Resource
Dim Task_As As Assignment
Dim Reso_As As Assignment
Dim Job As Task
For Each Reso In ActiveProject.Resources
If Not Reso Is Nothing Then
For Each Reso_As In Reso.Assignments
'Reso_As.Text2 = Reso.Text2
Set Job = ActiveProject.Tasks(Reso_As.TaskID)
For Each Task_As In Job.Assignments
If Task_As.ResourceID = Reso.ID Then
Task_As.Number1 = Reso_As.Number1
End If 'TaskID
Next Task_As
Next Reso_As
End If 'Nothing
Next Reso
End Sub
 

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