Project 2003 Standard - Macro Filter/Sort/Renumber-Tasks

Y

y7c4g2k5

Attempting to set up a macro that runs a filter, sorts the task
selected by 'finish date', and finally renumbers the tasks based on th
sort order. The tasks involved are not summary tasks and the filter i
'active selection' using a flag field to mark the tasks to b
selected/sorted. Thank you - y7c4g2k
 
J

Jan De Messemaeker

That is straightforward using the Sort method with the option to renumber
but!! renumber will only work when Keep outline structure is on:

Sort Key1:="Finish", Ascending1:=True, Renumber:=True,Outline:=True

HTH
 
Y

y7c4g2k5

Thank you Jan for the quick response - it was the 'outline:true' that
had wrong - macro works fine now - thanks again
 
Y

y7c4g2k5

Jan - still having a problem with 'Renumbering' of tasks - code show
below -
thanking you in advance.

Sub RenumberSelectedTasks()

Application.Calculation = pjManual

Dim jTasks As Tasks
Dim jTask As Task
Dim Outline As Boolean

For Each jTask In ActiveProject.Tasks
If Not jTask Is Nothing Then
jTask.Flag5 = "No"
End If
Next jTask

Set jTasks = ActiveSelection.Tasks
For Each jTask In jTasks
If Not jTask Is Nothing Then
jTask.Flag5 = "Yes"
End If
Next jTask

FilterEdit Name:="Select", Taskfilter:=True, Create:=True, _
OverwriteExisting:=True, FieldName:="Flag5", Test:="equals", _
value:="Yes", ShowInMenu:=False, ShowSummaryTasks:=False

FilterApply Name:="Select"
'**** TASKS ARE NOT BEING RENUMBERED???? ****
Sort key1:="Finish", Ascending1:=True, Renumber:=True
Outline:=True

FilterApply Name:="&All Tasks"
Sort key1:="ID", Ascending1:=True

For Each jTask In ActiveProject.Tasks
If Not jTask Is Nothing Then
If jTask.Summary Then
If jTask.PercentComplete = 100 Then
jTask.OutlineHideSubtasks
End If
End If
End If
Next jTask

Application.Calculation = pjAutomatic

End Su
 
J

Jan De Messemaeker

Hi,

OK, you made me try it and here's the diagnostic:
Renumber only works when all tasks are visible (the filter is all tasks) -
same when sorting manually.
If you only want to renumber certain tasks this is how i would try it.
In your procedure create a number field as follows:
If no renumbering is needed, field=ID
If renumbering is needed, field=ID of first in the selection
Then sotrt by number field first, finish second.

Hope this helps.
 
Y

y7c4g2k5

Jan,
Something got lost in the translation - attempted to follo
instructions but never was able to accomplish the renumbering of tasks
Thank you
 
Y

y7c4g2k5

Jan,
Found one of your earlier responses to another questions which solve
the problem I've been having - I should have explained the proble
differently - thanks again
 
Y

y7c4g2k5

Jan,

What is the vba code to copy the corresponding summary task ID to a
custom field for all subtasks. Thank you.
 
M

Mike Glen

Hi Jan,

Try posting on the server newsgroup as this one is closing down. Please see
FAQ Item: 24. Project Newsgroups. FAQs, companion products and other useful
Project information can be seen at this web
address:http://project.mvps.org/faqs.htm .

Mike Glen
Project MVP
 
J

Jan De Messemaeker

Hi,

Please:

For each job in activeproject.tasks
if not job is nothing then
if job.outlinelevel>1 then 'if not it doesn't have an outline parent
job.number8=job.outlineparent.id
end if
end if
next

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