Hello, I want to customize one field in Gantt Chart that shows only Material Cost of Tasks. I got a reply form Microsoft that we need VBA procedure for that. Anybody having some idea about VBA Procedure to customize Material Cost Field in MSP 2003. Help me! Thanks & Regards, Jaya
Something like the following will work: Sub MaterialsCost() Dim Tsk As Task Dim Res As Resource Dim Assgn As Assignment For Each Tsk In ActiveProject.Tasks If Not Tsk Is Nothing Then Tsk.Cost1 = 0 For Each Assgn In Tsk.Assignments Set Res = ActiveProject.Resources(Assgn.ResourceID) If Res.Type = pjResourceTypeMaterial Then Tsk.Cost1 = Tsk.Cost1 + Assgn.Cost End If Next Assgn End If Next Tsk End Sub Insert teh column Cost1 to see the results. -- Rod Gill Microsoft MVP for Project Author of the only book on Project VBA, see: http://www.projectvbabook.com "Jayalakshmi" wrote in message news:42A15D39-BE62-4E18-B060-A72B964B0E61@microsoft.com... > Hello, > > I want to customize one field in Gantt Chart that shows only Material Cost > of Tasks. > > I got a reply form Microsoft that we need VBA procedure for that. > > Anybody having some idea about VBA Procedure to customize Material Cost > Field in MSP 2003. > > Help me! > > Thanks & Regards, > Jaya > >
Hi Gill, Thanks a Lot. Its working fine..... Regards, Jaya "Rod Gill" wrote: > Something like the following will work: > > Sub MaterialsCost() > Dim Tsk As Task > Dim Res As Resource > Dim Assgn As Assignment > For Each Tsk In ActiveProject.Tasks > If Not Tsk Is Nothing Then > Tsk.Cost1 = 0 > For Each Assgn In Tsk.Assignments > Set Res = ActiveProject.Resources(Assgn.ResourceID) > If Res.Type = pjResourceTypeMaterial Then > Tsk.Cost1 = Tsk.Cost1 + Assgn.Cost > End If > Next Assgn > End If > Next Tsk > End Sub > > Insert teh column Cost1 to see the results. > > -- > > Rod Gill > Microsoft MVP for Project > > Author of the only book on Project VBA, see: > http://www.projectvbabook.com > > > > "Jayalakshmi" wrote in message > news:42A15D39-BE62-4E18-B060-A72B964B0E61@microsoft.com... > > Hello, > > > > I want to customize one field in Gantt Chart that shows only Material Cost > > of Tasks. > > > > I got a reply form Microsoft that we need VBA procedure for that. > > > > Anybody having some idea about VBA Procedure to customize Material Cost > > Field in MSP 2003. > > > > Help me! > > > > Thanks & Regards, > > Jaya > > > > > >