Custom Field indicating if predecessor tasks are complete

R

RyanT

So I'm looking to create a custom field column (eg. Flag5) that indicates
'yes' or 'no' whether the predecessors for any given task are complete
(100%). The only possible solution I can think of is a macro. I have one
that works but I would like to implement it so that it updates when there is
any change to the data in the project. Here's what I have:

Private Sub PredEdit()

Dim countTsk As Task
Dim checkTsk As Task
Dim allTsks As Tasks
Dim predTsks As Tasks
Dim i As Single
Dim j As Single

Set allTsks = ActiveProject.Tasks

For Each countTsk In allTsks

Set predTsks = countTsk.PredecessorTasks

i = 0

For Each checkTsk In predTsks
j = predTsks.Count

If checkTsk.PercentComplete = "100" Then
i = i + 1
End If

If j = i Then
countTsk.Flag5 = "Yes"
Else
countTsk.Flag5 = "No"
End If

Next checkTsk

Next countTsk

End Sub

Perhaps this isn't the best way to accomplish this task. I'm open to any
ideas. Thanks.

-Ryan
 
J

Jan De Messemaeker

Hi,

I recently posted a slightly more elegant coding to this, it looked about
like this

for each job in activeproject.tasks
if not job is nothing then
if not job.summary then
job.flag5=true
for each Pred in job.predecessortasks
if not pred.percentcomplete=100 then
job.flag5=false
exit for
end if
next pred
end if
end if

I would put this is a before save event to make it automatic.
Hope this helps,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 

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