Sort versus order tasks are looped over

C

Carl

I've got a bit of code that sorts tasks based on Text1, then it loops over
the tasks looking at all the Text1 fields. After I run the macro I can
examine the schedule and the sort looks correct, everything in alphabetical
order. But when I loop over the tasks, the Text1 values I get are not
alphabetical (looks like they're in ID order). How do I iterate over all
tasks in Text1 order?

-- Carl
 
C

Carl

Here's my code:

Sub SortedTaskLoop()
Dim Tsk As Task
ActiveProject.Tasks.Application.Sort Key1:="Text1", Renumber:=False,
Outline:=False
For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then ' test for blank rows
Debug.Print Tsk.ID; Tsk.Text1
End If
Next Tsk
End Sub

-- Carl
 
C

Carl

Jack,

Thanks for the suggestion, switching to SelectAll and ActiveSelection did
the trick!

-- Carl
 

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