Question

I'm new to MS Project and I need help on something that I don't know if It's possible to do. In a list of hundreds of tasks, I need to hide some, based on a criteria. This First step is easy, I've created a filter with the criteria that I wanted, applied it to the tasks and it worked well.

The problem is that I need to change duration of tasks that became hidden by the filter, that is, change its duration to 0 so it impacts durations of the other tasks in the list. And by filtering, the only thing that is done is hide tasks from the view, but they still there, and so the dates and durations remain intact.

Is there anyway that I can hide tasks, and set its duration to 0? Can be through VBA also, because I worked with VBA before, not in Project, but in Access and Excel.

Was it helpful?

Solution

If you have MS Project 2010 or later, you can set the tasks inactive (right mouse button / inactivate task). This makes duration etc. not affecting other tasks any more even if still stated in the inactive tasks. Otherwise, a macro like this should help:

Dim tskX As Task
For Each tskX In ActiveProject.Tasks
    If Not (tskX Is Nothing) Then               'Do not combine this line with any other line! You would get runtime errors when accessing empty tasks (space rows) in your schedule.
        If Not tskX.ExternalTask Then           'You can't modify external linked tasks anyhow. You would get runtime errors if trying this.
            If tskX.Text1 = "x" Then            'Instead of "Text1" you can access the field containing your criteria here
                tskX.PercentWorkComplete = 0
                tskX.Duration = 0
                End If
            End If
        End If
    Next tskX

Best regards, Kawi42

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top