Thanks for your suggestions/help. I checked to make sure that all of
the loops use "Exit For" when appropriate. I am using Excel 2007 which
*could* be causing some of the slowdown, but Excel only really comes
in at the end for result output, it could explain why my speed tests
are so slow (I've been outputting the time for some functions to
complete to Excel). The following function seems to be taking up a
good chunk of the time:

'create a list of tasks that are eligible to run
Private Function GetEligibleTasks() As Collection

    Dim eligible_tasks As New Collection
    Dim t As cTask

    For Each t In tasklist

        'make sure the task hasn't been started yet
        If t.Status = 0 Then

            t.StartDate = tracker.CurrentDate

            'make sure it can be started
            If t.ReadyToStart() Then

                eligible_tasks.Add t
 
eligible_tasks.item(eligible_tasks.count).EligibleTaskIndex =
eligible_tasks.count

            End If
        End If

    Next t

  Set GetEligibleTasks = eligible_tasks
End Function

'determine if a task is ready to start by checking
'whether its predecessors have completed
Public Function ReadyToStart() As Boolean

    Dim pred As Tasks
    Dim j As Integer
    Dim start As Date
    Dim p As task

    Set pred = ActiveProject.Tasks(Index).PredecessorTasks 'get a list
of the preceeding tasks

    'if the task has no predecessors, it's ready to run
    If pred.count = 0 Then
        ReadyToStart = True
        Exit Function
    End If

    For Each p In pred

        Dim test As Date
        test = p.Finish

        'if a predecessor hasn't been completed, this task isn't ready
to run
        If tasklist.item(p.ID).Status <> 2 Then
            ReadyToStart = False
            Exit Function

        Else
            ReadyToStart = True
        End If
    Next

End Function


In this case tasklist is a Collection. To me, it doesn't look like
this could get much more efficient - any suggestions? (I can't post
the whole project because it's company protected information)

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

To unsubscribe from this group, send email to 
excel-macros+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to