Task duration based on calculation

C

Chris

I'm new to project and am trying to figure out how to create a task that will
calculate it's duration. The scenario is this:

It is estimated that a task will take 20mins per user.

I want to be able to change the number of users per task and have the task
calculate the duration.

Do I need a custom field that contains the number of users? or is there
another way of doing this (probably staring me in the face if the truth be
known)
 
J

Jan De Messemaeker

Hi Chris,

It's definitely not obvious.
Duration is a calculated field, not a custom field, and hence cannot have a
user formula.
If you know some VBA you could indeed create 2 custom fields (users and time
per user), say Number1 and Duration1; insert the following macro in a VBE
module (how to follows the macro):

Sub Custom_Duration()
For each Job in activeproject.tasks
if not Job is nothing then
if not job.percentcomplete=100 then
'Finished tasks should not be recalculated I guess
if job.number1>0 then
job.duration=job.number1*job.duration1
end if
end if
end if
next job
end sub

Alt+F11
Left upper window select ProjectGlobal
Insert, Module
In the upcoming code window paste the above procedure
The macro can now be run from Tools, Macros, Macro.

Hope this helps
 
M

Mike Glen

Hi Chris,

Welcome to this Microsoft Project newsgroup :)

This sounds like Project's efforte driven settings. If you set up the 20min
duration task, then add another resource, the duration should halve to 10
mins. Do you not observe this effect?

FAQs, companion products and other useful Project information can be seen at
this web address: http://project.mvps.org/faqs.htm

Hope this helps - please let us know how you get on :)

Mike Glen
MS Project MVP
 
C

Chris

Thanks Jan, that was right on the money........ is there any way of
triggering the macro once the Number1 custom field is updated?
 
C

Chris

Thanks Mike, I have seen this effect, but I need to get the task duration
before I assign resources to it. Jans previous post solved the problem for me.
 
J

Jan De Messemaeker

Hi Chris,

I'm not a champion in event-driven VBA but I know the only event that you
could use is ProjectBeforeTaskChange and that would react to any change in a
task.
Looks like you better creata a button on the toolbar that triggers the
macro, it's then only one click to update.
HTH
 
G

Greg

There is another way to do that without VBA, though you seem to be
comfortable with VBA.

Say you use Number2 to be the number of users, and number 3 to be the
constant 20 mins per user. As you identify new users, you increase the value
in field Number2.

Now create a calcluated field in Text2, with the formula
Str([Number2]*[Number3]) & " " & "mins" … Be sure to include the quotes as
shown.

Then right click on the cell Text2, do a "Copy Cell".

Then right click the duration field, do a "Paste Special", select "Paste
Link" and enter. If the link is successfully created, you see a small, gray
triangle in the lower right-hand corner of the duration cell.

From then on, the duration of that task will change whenever you add or
subtract users by changing the value of number2.

You have to set up this link in the duration field for each task that has
its duration calculated this way.
 

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