How to Split Labor & Material Cost on Task view

J

Jan

Is there away in Taskview (cost table) to show a column with work cost
(labor) and a column for material cost? I have been banging my head for 2
days. Any help will be greatly appreciated.
 
J

Jan De Messemaeker

Hi Jan,

(How could I not help someone with such a fine name?:))
I'm afraid you will need some development (VBA for instance) for that.
 
J

Jan

Hi Jan (the knife maker?)

I suspected this was going to be the case. I'm not affraid of VBA. Any ideas
on where to start. I'm new to MS Project. (excel vba experience). My gut feel
is Cost1 & Cost 2 will have to store the values, with VBA doing the data
collection and calcs. Does that sound about right or am I on the wrong path?
Thanks
Jan
 
J

Jan De Messemaeker

Hi Jan,

First, thanks for the translation - in English my name sound like the
mess-maker, which is not that clean.
Then, here's a snippet thet may help you:

Dim Job as task
Dim Iemand as resource
Dim Widoewa as assignment
For each job in activeproject.tasks
if not job is nothing then
job.cost1=0
job.cost2=0
for each widoewa in job.assignments
if widoewa.resourcetype=pjResourceTypeWork then
job.cost1=job.cost1+widoewa.cost
end if
if widoewa.resourcetype=pjResourceTypeMaterial then
job.cost2=job.cost2+widoewa.cost
end if
next widoewa
end if
next job

Hope this helps,
 
J

Jan

Jan
Thank you so much. That did it.

Now I have to figure out how to make the values total for the summary tasks.
I think with enough tinkering I will figure it out.

Thank you again so much.

Jan
 
J

Jan

In the interrest of helping someone else here is what I came up with to show
Labor and Material colums. Thus is a Sub and not a function so it has to be
ran manaully everytime you want to calc the values. Thanks Jan for all your
help.

Sub CalcLaborMaterial()


Dim Job As Task
Dim Iemand As Resource
Dim WieDoenWat As Assignment

CustomFieldPropertiesEx FieldID:=pjCustomTaskCost1,
Attribute:=pjFieldAttributeNone, _
SummaryCalc:=pjCalcNone,
GraphicalIndicators:=False, _
AutomaticallyRolldownToAssn:=False
CustomFieldPropertiesEx FieldID:=pjCustomTaskCost2,
Attribute:=pjFieldAttributeNone, _
SummaryCalc:=pjCalcNone,
GraphicalIndicators:=False, _
AutomaticallyRolldownToAssn:=False


For Each Job In ActiveProject.Tasks
If Not Job Is Nothing Then
Job.Cost1 = 0
Job.Cost2 = 0
End If
Next Job

For Each Job In ActiveProject.Tasks
If Not Job Is Nothing Then
Job.Cost1 = 0
Job.Cost2 = 0
For Each WieDoenWat In Job.Assignments
If WieDoenWat.ResourceType = pjResourceTypeWork Then
Job.Cost1 = Job.Cost1 + WieDoenWat.Cost
End If
If WieDoenWat.ResourceType = pjResourceTypeMaterial Then
Job.Cost2 = Job.Cost2 + WieDoenWat.Cost
End If
Next WieDoenWat
End If
Next Job

CustomFieldPropertiesEx FieldID:=pjCustomTaskCost1,
Attribute:=pjFieldAttributeNone, _
SummaryCalc:=pjCalcRollupSum,
GraphicalIndicators:=False, _
AutomaticallyRolldownToAssn:=False
CustomFieldPropertiesEx FieldID:=pjCustomTaskCost2,
Attribute:=pjFieldAttributeNone, _
SummaryCalc:=pjCalcRollupSum,
GraphicalIndicators:=False, _
AutomaticallyRolldownToAssn:=False

For Each Job In ActiveProject.Tasks
If Not Job Is Nothing Then
Job.Text1 = "Labor:" & FormatCurrency(Job.Cost1, 0) & _
" <--> Material:" & FormatCurrency(Job.Cost2, 0)
End If
Next Job

End Sub
 
N

Nathan Thomas

This works great. However, I have resources applied to the parent levels to oversee a group of assignments. this sub does not add up the labor involved with those resources. is there any way to get those resource costs to add up in these custom fields?

Thanks,
Nathan
 

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