In MS Project (2013) can anyone show me how to copy a resource custom field (from the resource view tab) to a subproject tasks' custom field (task view tab)? Found the following to copy from an assignment field (resource usage view) to task field but I've no idea how to address a resource field...
Sub CopyAssignmentFieldToTask()
Dim t As Task
Dim ts As Tasks
Dim a As Assignment
Set ts = ActiveProject.Tasks
For Each t In ts
If Not t Is Nothing Then
t.Text5 = ""
For Each a In t.Assignments
'change the following line to use
'for a different custom field
t.Text5 = t.Text5 & ", " & a.Text5
Next a
End If
Next t
End Sub
source: http://zo-d.com/blog/archives/programming/working-with-task-and-assignment-fields-vba.html
edit: many thanks Rachel... for future ref, here's the complete answer which cycles through subprojects:
Sub CopyResourceUnitstoTasksv2()
Dim t As Task
Dim a As Assignment
Dim mProj As Project
Set mProj = ActiveProject
For Each Subproject In mProj.Subprojects
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
For Each a In t.Assignments
t.Number2 = a.Resource.Number1
Next a
End If
Next t
Next Subproject
End Sub