Home > Blog

How to remove redundant constraints from an MS Project plan

Often, over time, a project plan can become cluttered with constraints which aren't setting the dates for tasks and milestones.   Rather, the logic within the plan (predecessors and successors) rightly drives the dates in the plan.

This can happen as a task's date was initially set by a constraint, for instance; that the task can't be done until someone returns from holiday.  Then, the preceding tasks move and the logical linking pushes out the task.  Or the task was initially a little lacking in the predecessor / successor logic, which was then added and now controls the date.

In these instances, it can become hard to see what is actually date-constrained in the plan as many things have the date-constrained icon in the indicator column, but most of them aren't in reality date-constrained.

Below is some simple VBA that will remove any date "start no earlier than" or "finish no earlier than" constraint that isn't needed.

Sub Constraint_removal_2()

 

'see https://learn.microsoft.com/en-us/office/vba/api/project.pjconstraint for the types and values of constraints

 

Dim t As Task
Dim n As Long
Dim c As Integer
 
'zero counts
n = 0
c = 0
 
For Each t In ActiveProject.Tasks
    If Not (t Is Nothing) Then 'ignores blank lines
        If t.Summary = True Or t.ExternalTask = True Or t.ConstraintType = 0 Or t.PercentComplete = 100 Then 'ignores summary, completed, external rows or those "start as soon as possible"
            'do nothing
        Else
            If t.ConstraintType = pjFNET Then 'Finish no earlier than
                If t.ConstraintDate < t.finish Then
                    t.ConstraintType = 0 'if the finish constraint is earlier than the current finish date, remove it
                    n = n + 1
                Else
                    c = c + 1
                End If
            End If
            If t.ConstraintType = pjSNET Then 'start no earlier than
                If t.ConstraintDate < t.Start Then
                    t.ConstraintType = 0 'if the start constraint is earlier than the current start date, remove it
                    n = n + 1
                Else
                    c = c + 1
                End If
            End If
        End If
    End If
Next t
 
MsgBox n & " redundent 'start or finish no earlier' than constraints removed from your plan.  " & vbCrLf & c & " constraints that remain are driving their task date."
 
End Sub
Miles Goodchild

Miles Goodchild has been a Program and Programme Planner, PMO lead and Project Manger since 1998.  He enjoys using MS Office, especially Project, Excel and Visio to make life easier and simpler.  In the course of this he created SummaryPro.  In this blog he shares some of the tips and techniques he has learnt over the years in the hope that they will be useful to you.