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
188.8.131.52. If number of dependencies is greater than zero, then mark it.
1.1.2. If the task is not summary task
184.108.40.206. 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".
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.