User Defined Function or Function for Phase Duration

R

RixMcx

Sub GetPhaseDuration()

Dim start As Date
Dim Finish As Date
Dim Duration As Integer
Dim PhaseDuration As Integer

For Each Task In active.Project.Tasks
If Task.Summary Then
PhaseDuration = Task.Summary.Duration
End If
If Not Task.Summary Then
task.outlineparent.Duration
End If
End Sub

I am trying to create a field that displays Phase duration or PhaseStart and
PhaseFinish to use in a formula. I have read similar posts but I am a little
rusty at VBA. I have used VBA in Word, Access and Outlook so hopefully with
a little direction I can do this.

Thanks
 
R

Rod Gill

Hi,

Try:

Sub CopyPhaseDurationToDuration1()
Dim Tsk As Task
For Each Tsk In Active.Project.Tasks
If Not Tsk Is Nothing Then 'Test for blank rows
If Tsk.Summary Then
Tsk.Duration1 = Tsk.Duration
Else
Tsk.Duration1 = Task.OutlineParent.Duration
End If
End If
Next Tsk
End Sub


--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




RixMcx said:
Sub GetPhaseDuration()

Dim start As Date
Dim Finish As Date
Dim Duration As Integer
Dim PhaseDuration As Integer

For Each Task In active.Project.Tasks
If Task.Summary Then
PhaseDuration = Task.Summary.Duration
End If
If Not Task.Summary Then
task.outlineparent.Duration
End If
End Sub

I am trying to create a field that displays Phase duration or PhaseStart
and
PhaseFinish to use in a formula. I have read similar posts but I am a
little
rusty at VBA. I have used VBA in Word, Access and Outlook so hopefully
with
a little direction I can do this.

Thanks

__________ Information from ESET Smart Security, version of virus
signature database 5089 (20100505) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5089 (20100505) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

RixMcx

Thanks Rod, I pasted the code into a module and tried to run the code and I
got a 424 error with this line highlighted

For Each Tsk In Active.Project.Tasks
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 
R

Rod Gill

My typo, that should be ActiveProject (all one word).

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




RixMcx said:
Thanks Rod, I pasted the code into a module and tried to run the code and
I
got a 424 error with this line highlighted

For Each Tsk In Active.Project.Tasks



__________ Information from ESET Smart Security, version of virus
signature database 5090 (20100506) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5090 (20100506) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 
R

RixMcx

Sorry to be back with another Error;

Tsk.Duration1 = Tsk.Duration is highlghted and has a 1101 code that states
"no code mask defined for duration1"

Thanks for the help
 
R

Rod Gill

That sounds like you have customized that field.

1) Select Tools, Fields, Customize
2) Make sure that None is checked for custom attributes and not Lookup

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




RixMcx said:
Sorry to be back with another Error;

Tsk.Duration1 = Tsk.Duration is highlghted and has a 1101 code that states
"no code mask defined for duration1"

Thanks for the help



__________ Information from ESET Smart Security, version of virus
signature database 5092 (20100506) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5092 (20100506) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

Rod Gill

Happy coding!

--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




RixMcx said:
Thanks Rod, you helped me create my first module in Project VBA. It works
great



__________ Information from ESET Smart Security, version of virus
signature database 5093 (20100506) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 5093 (20100506) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
R

RixMcx

Rod, I am back with a question. is there a way to get the value from say
"outline level 3". The problem is I want the Design Phase duration or build
Phase duration value. I want the subtasks to inherit the Phase Duration
instead of the parent duration. Is there a .grandparent. just kidding

i.e Design 180 days
Card design 90 days
90 task
90 task
software design 90 days
90 task
90 task

how do I get the phase value of 180 for each task? thanks. I ordered your
book over the weekend, looking forward to it
 

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