Trying to count subproject tasks

D

Dave Hollas

Hi All,

Really need some help here. I'm attempting to count the alike task name in
the subproject of a consolidated project file. I think I need to set the
tasks and tasks to something. But I don't know what. Any help would be
appreciated.


Dave


Sub TheThingCount()
Dim oT As Task
Dim oTs As Tasks
Dim iCount As Integer
Dim SubProj as Subproject

For Each SubProj In ActiveProject.Subprojects
For Each oT In oTs
If Not oT Is Nothing Then
If oT.Summary = False Then ' I wanted to optimize the process
by filtering out summary task type
If oT.Name = "The Thing Name" Then
iCount = iCount + 1
End If
End If
End If
Next oT
Next Subproject
End Sub
 
J

JackD

Dave,

Here is a some code I posted for someone who wanted to work with the task
names within a subproject:

-----snip--------
Sub subprojectstuff()
Dim subproj As Subproject
Dim myproj As Project
Dim t As Task
'go through all the subprojects in the file
For Each subproj In ActiveProject.Subprojects
'open them all in turn
FileOpen (subproj.Path)
Set myproj = ActiveProject
'when open loop through all tasks in the subproject
For Each t In myproj.Tasks
'set the name the way you like (or use text field etc.)
t.Name = subproj.Parent & " - " & t.Name
Next t
FileClose pjDoNotSave
Next subproj
End Sub

--snip---------

That should give you enough information to do what you want to do.
An alternative to checking each task is to use a filter and then you can use
activeselection.tasks.count

-Jack
 
D

Dave Hollas

Hi Jack,

Thanks for the help. It worked out fine using your method and suggestion of
Activeselection.task.count.
Dave
 

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