Stop! Don’t delete approved tasks

In my earliest post, you learnt about how to use Calculate Event procedure in the Project object to color tasks with no dependencies set. The events of Project are available for any open project – reference

You have a more powerful object called Application. It represents the entire Project application. To write event procedures for the Application object, you must follow a new approach.

Let’s take an example to illustrate Application object’s event procedure. As a best practice, it is advisable not to delete baseline tasks since you will lose the evidence and will have incorrect variance. It is hence recommended to Inactivate the task (see this blog about the benefits).

Design and Build tasks is approved and Test task is inserted later.

After deleting Build task, you lost the proof that Build was part of your plan

The following steps will guide you how to create event handler before a task is deleted

1. Click View tab. Click Macros dropdown and select Visual Basic

2. In the Visual Basic Editor, on the option menu for VBAProject, choose Insert, and then choose Class Module to create a class named Class1.

3. You can rename the class module in the Properties pane. In the following examples, the class is named Events.

4. You must create a new object using the WithEvents keyword in a class module
Public WithEvents App As Application
5. Now change the object and procedure to "App" and "ProjectBeforeTaskDelete". ProjectBeforeTaskDelete event will be fired for every task that is deleted.

6. Within this sub-routine include the below code

7. You need to bind the current Application object to the App object declared in the class to fire the events. Open the ThisProject module and paste the below code. This code declares an object X of type Events (the class module we created earlier), and sets the current Application object to the App object of Events class module

The code displays the message "Dont’ delete baseline task. Instead Inactivate the task" and cancels the delete action if the Baseline Start of the task deleted is set.


Get alerted when tasks have no dependencies set

In my previous blog post "Highlight items after every change", you have learnt how to apply highlight the tasks after every change by using Visual Basic for Applications macro.

Best practice followed when linking tasks is (a) Don’t link summary tasks to summary task – as it complicates the scheduling logic, (b) Every other task should have at least one predecessor or successor task.

It is easy to validate the above provide your plan is small (this is quite relative again 🙂 ). In this blog post, I will walk through on how VBA macros can color tasks automatically with no dependencies set and color summary tasks with dependencies set.

In the above plan, you can notice I have violate the first rule (a) Phase 1 (task id 1) is linked to Phase 2 (task id 4), (b) Go Live (task id 7) is not linked to any other tasks

Let’s start with a pseudocode for this requirement.

1. For each task in plan do
1.1. If task is not empty and active
1.1.1. If the task is summary task If number of dependencies is greater than zero, then mark it.
1.1.2. If the task is not summary task If number of dependencies is zero, then mark it
2. Color the marked task

Now you need to translate each statement by using Project model object, properties and methods.

1. Click View tab. Click Macros dropdown and select Visual Basic

2. In the editor, double click your current project on the left panel.
3. Now change the object and procedure to "Project" and "Calculate".

4. This will include a private sub-routine which will be invoked automatically after calculation!!

5. Within this sub-routine, include the below script

The above sub-routine checks if the current view is Gantt Chart. Then, it changes the text styles of marked tasks (Item:=5) to default color. Then, we loop through the task list and mark the tasks having the issues.

After closing the editor, I just retyped a task information and Project automatically colors the task that need attention in red.

Highlight items after every change

Project 2013 gives features to highlight, filter and group tasks on certain conditions. These commands are available in View ribbon.

I have selected the criteria "Critical" in Highlight list, and Project highlights the critical tasks with yellow background color.


Now, I changed the duration of Build 2 to 4 days. This task doesn’t get highlighted though it is part of the critical path. Why?

After selecting the criteria, Project applies it only once in the current view. In other words, Project doesn’t refresh the view after every change.

You need to write a small script that will be apply the filter after every change, and this is quite simple.

1. Click View tab. Click Macros dropdown and select Visual Basic

2. In the editor, double click your current project on the left panel.
3. Now change the object and procedure to "Project" and "Change".

4. This will include a private sub-routine which will be invoked automatically after every edit!!

5. Within the sub-routine, include the below script. This code applies the Critical filter if the current view is "Gantt Chart"
If pj.CurrentView = "Gantt Chart" Then
FilterApply Name:="Critical", Highlight:=True
End If

6. Close the editor.

Now, I changed the duration of Build 2 to 5 days and Project automatically highlights the critical tasks 🙂

Make % Complete and % Work Complete Independent

In my earlier post "The Purpose of ‘% Complete’ field", I mentioned how % Complete, % Work Complete and Physical % Complete are different from each other.

By default, updating % Complete will update % Work Complete as seen below

Is there a way to make % Complete and % Work Complete independent?

Click Project, Options. Select Schedule tab. Clear "Updating Task Status updates Resource Status" checkbox in Calculation options for this project: section.

Now, updating actual duration, remaining duration or even % Complete will not update % Work Complete, Actual Work, Remaining Work of the task

In the above example, updating % Complete to 50% will not update % Work Complete which needs to updated manually.

Difference between Scheduled Start/Scheduled Finish and Start/Finish

Start and Finish fields is often called as the current/schedule start and finish.

In Project 2007 and earlier versions, these fields are adjusted based on calendar, predecessor and constraints. These fields are date fields.

In Project 2010 and later version, Microsoft introduced the Task Mode. This special field can be set to Manually Scheduled or Auto Scheduled.

By default, new tasks are created as Manually Scheduled tasks. This means their Duration, Start, Finish will be empty. This implies Start and Finish fields are text fields and not date fields.

When you link this task to another task, Project will default the duration to 1 day?, and calculate the Start and Finish field, but this will happen only once. Are you wondering why does this done only once? In File, Options, Schedule tab, by default "Update Manually Scheduled tasks when editing links" is checked.

I have written another post "The Little Benefits of Manually Scheduled Tasks". As mentioned in this post, Project draws a green wavy or red wavy line below the Finish date to tell the task needs to finish early or needs to finish late.

Without changing the task mode, how to see the recommended start and finish of the manually scheduled task?

Scheduled Start and Scheduled Finish fields displays the recommended Start and Finish as calculated by Project based on dependencies, constraints and calendars. This field can be used in custom formula and conditions.

What are you finishing today?

Project 2013 ships with "Tasks Due This Week" filter. This filter shows detail tasks with finish between the start and end of the current week.

What if you want to display the tasks due today?

1. On the View tab, click the down arrow of the Filter box to display the drop-down menu and then select New Filter in the menu to open the Filter Definition dialog box.
2. Enter the name "Tasks Due Today" and set the filter criteria as it is seen below and click Save:

The value string “Today is:”? evaluates to the Current Date field entered in Project Information dialog box. If we use a different prompt string, for example, "Enter a date:"?, then the filter asks for a date to compare with the task finish dates.

3. On the View tab, select the filter "Tasks Due Today" from Highlight: dropdown (by default "No Highlight" is applied)

So, what are you finishing today?

How to calculate planned % Complete?

You have updated the work progressed in % complete field, but there is no Project field that will give you the planned % based on the status date.

Create a custom field using a formula calculation the planned % complete, based on the status date.
1. Field : Expected minutes to status date (Number1)
– Insert a Number1 field in Gantt Chart.
– Right Number1 field and choose Custom Fields.
– Under Custom attributes, click Formula and type the below text
IIf([Status Date]<[Baseline Start],0,IIf([Status Date]>[Baseline Finish],[Baseline Duration],Abs(ProjDateDiff([Baseline Start],[Status Date]))))
– Under Calculation for tasks and group summary rows, choose Rollup with dropdown as sum
2. Field : Expected % complete (Text1)
– Insert a Text1 field in Gantt Chart.
– Right Text1 field and choose Custom Fields.
– Under Custom attributes, click Formula and type the below text
IIf([Status Date]=ProjDateValue(‘NA’),”No Status Date”,IIf([Baseline Start]=ProjDateValue(‘NA’),”No BL”,FORMAT([Number1]/[Baseline Duration],”0%”)))