Predecessor Driven Completion

M

Mike Roosevelt

I am attempting to drive completion of a task by marking the completion of
its predecessor tasks. That is, given task A with predecessors 1-8, I would
like task A to show incremental increases in completion % whenever I check
off one of the predecessor tasks as 100% complete. Is this possible to do or
could someone help me write a macro for it?
Thanks!
Mike
 
J

Jan De Messemaeker

Hi,

This is about the same macro I wrote earlier this week for the automatic
completion of a milestone.
Here is a version (I put % complete to vary linearly by number of tasks
complete; it could be by duration or work of course)
Select the successor then run the macro.
Hope this helps,


Sub SucComp()
dim Job as Task
dim step as single
Dim Suc as task
set suc=activeselection.tasks(1)
step=100/suc.predecessortasks.count
for each job in suc.predecessortasks
if job.percentcomplete=100 then
suc.percentcomplete=suc.percentcomplete+step
end if
next job
end sub
 
M

Mike Roosevelt

Thanks! That works almost perfectly! Not knowing anything about VBA I don't
know how to fix it. So in my example, Task A has 6 predecessor tasks. That
would be 16.7% for completion of each. When I check off predecessor 1 as
being 100% complete and run the macro, I get 17% - this is good. However,
when I have 2 complete predecessor tasks, it rises to 51% (should be 33-34%).
When I have 3, I get a bug that says "invalid percent complete" and brings
me to the line:

suc.percentcomplete=suc.percentcomplete+step

Is there something in this line I need to change? When I end the debugger
at this point, I see that the percent complete of Task A has risen to 85%
(here is where it should be 50% as 3/6 tasks are marked complete)

Thanks,
Mike
 
J

Jan De Messemaeker

Hi,

Sorry, that's what you get from publishing code without testing...
Following the line set suc= add this line:
suc.percentcomplete=0

Hope this helps,
 

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