Show Sub Tasks for filtered Level 3 tasks meeting a criteria

P

Peter Rooney

With reference to me earlier post of copying and pasting only visible rows, I
decided to try to write some code to test for tasks allocated to a certain
sub team in my department (in this example, "Core Tools", as shown below)

There are a number of level 2 tasks, each split into a number of level 3
teams thus:
Project 1
Team 1
Activity 1
Activity 2
Team 2
Activity 1
Activity 2
Project 2 etc etc

and each has various levels of sub task below that, sown to about level 7 or
8.

I filter the plan so that it looks something like this, to show my "Core
Tools" team activities

Project 1
Core Tools
Project 2
Core Tools
Project 3
Core Tools

etc etc

What I want is to test all tasks, and where the Level 3 task is shown as
"Core Tools" (for example), show ALL the subtasks for the task to show
something like:

Project No. 1 (level 2 task)
Core Tools (level 3 task)
Level 4 task
Level 5 task
Level 4 task
Level 5 task
Level 6 task
Project No. 2 (level 2 task)
Core Tools (level 3 task)
Level 4 task
Level 5 task
Level 6 task

etc etc
---------------------------------------------------------------------------
Here's the code I wrote:

Sub AAMin()
Dim LoopTask As Task
SelectSheet
For Each LoopTask In ActiveSelection.Tasks
If Not LoopTask Is Nothing Then
If LoopTask.Name = "Core Tools" Then
LoopTask.OutlineShowSubTasks
End If
End If
Next LoopTask
End Sub

I did try getting it to select the row for the task that needs to be
unpacked - but if I did, my loop went wrong and couldn't find the next
matching row, as the selection had changed. - I thought that I'd be able to
use "OutlineShowSubTasks" as a method(?) for my Task object, "LoopTask", but
nothing happens and the outline tasks aren't shown. Doubtless someone will
have a more elegant way of doing it than me - help me out please, it's Friday
afternoon and I don't want to spend all weekend puzzling over this.

Thanks in advance

Pete Rooney
 
J

Jan De Messemaeker

Hi Peter,

I avoid selection objects. The more elegant way if you want to display some
tasks and not the other ones is to create a filte based on a flag fied and
set the field by VBA logic.
Something like this:

Sub ForPeter
Dim AnyJob as task
Dim SwitchOn as boolean
for each anyjob in activeproject.tasks
if not anyjob is nothing then
anyjob.flag7=false
if anyjob.outlinelevel<3 then
switchon=false
else
if (anyjob.outlinelevel=3) and (anyjob.name="Core Tools") then
switchon=true
end if
anyjob.flag7=switchon
end if
end if
next anyjob
end sub
Now filter for flag7=Yes showing summary tasks

(Untested!)

HTH
 
P

Peter Rooney

Hi Jan, I'll give it a go and let you know how I went on next week.
Have a good weekend!

Pete
 

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