Others

Create a Summary Task and Linked Subtasks in Microsoft Project with VBA

Jason MillerJason Miller Nov 27, 2026 869 views

Question details

Create a summary task and up to 20 linked subtasks using VBA.

Create a Summary Task and Linked Subtasks in Microsoft Project with VBA
Product
Microsoft Project
Device & OS
not provided
Scenario
A VBA user form collects an initiative name, tracking ID, iteration count, duration, and start date for a project schedule.
Observed behavior
The desired schedule has a level-1 summary task and level-2, fixed-duration subtasks, with effort-driven scheduling disabled and finish-to-start links between consecutive subtasks.
Before you start

Open the project in a desktop version of Microsoft Project that supports VBA, and use an unfiltered task view with the project summary task hidden when selecting rows by task ID. Check the project calendar and confirm that the requested start date is a working Monday.

Solution 1Recommended

Create and link the tasks sequentially in VBA

Use this approach when a user form should build an initiative and its iterations in the active Microsoft Project schedule.

A summary task derives its dates and duration from its subtasks, so configure the subtasks rather than assigning the summary task a fixed duration.

Finish-to-start links schedule each subsequent iteration after its predecessor, subject to the project calendar and any other constraints.

1
Validate the form inputs

In the user form's Create button procedure, check that the initiative name and tracking ID are present, the iteration count is an integer from 1 through 20, the duration is positive, and the start date is a valid Monday. Display a message and exit the procedure if a check fails.

2
Add the summary task

In the VBA editor, use ActiveProject.Tasks.Add to create the initiative task. Store the returned Task object, write the tracking ID to a field such as Text1 if appropriate, select its row in the unfiltered task view, and use SetToOLL 1 to place it at outline level 1.

3
Create and indent each subtask

Loop from 1 to the validated iteration count and use ActiveProject.Tasks.Add to add each iteration in order. Select each new task row and use SetToOLL 2 to indent it under the initiative. Because SetToOLL acts on the selection, verify that the intended row is selected before calling it.

4
Set scheduling properties

For each new Task object, set Manual = False, Type = pjFixedDuration, and EffortDriven = False. Set Duration with Application.DurationValue using the requested duration, such as a number of days followed by "d". Set the first subtask's Start to the validated start date.

5
Link and check the iterations

Keep a reference to the previous subtask. For each subtask after the first, set its Predecessors property to CStr(previousTask.ID); a predecessor ID without a link type specifies finish-to-start. Update the reference after each iteration, then inspect the Task Name, Duration, Start, and Predecessors columns in the task view.

Create and link the tasks sequentially in VBA
Check the resulting dates: The first task's scheduled start can be affected by working time, calendars, and constraints. Review the schedule after running the procedure rather than assuming every task will start on a particular calendar date.
Free Microsoft Office alternative

Track project iterations in WPS Spreadsheets

WPS Office is a free, lightweight alternative for maintaining a project iteration tracker in a familiar spreadsheet interface. Open compatible Microsoft Office files to move existing tabular plans into WPS; Microsoft Project scheduling and its VBA automation remain separate.

List initiatives, iteration dates, durations, and predecessor IDs in a spreadsheetOpen and edit Microsoft Excel XLSX filesUse a familiar interface for a straightforward move from Office spreadsheetsWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why shouldn't I set the summary task's duration directly?

Microsoft Project calculates a summary task's schedule from its subtasks. Set the duration and scheduling properties on each iteration, then review the resulting summary dates in the task view.

How do I make each iteration finish before the next one starts?

In VBA, set each subtask's Predecessors property to the previous subtask's ID. An ID without an explicit link type creates a finish-to-start dependency.

Where do I turn off effort-driven scheduling in VBA?

Set EffortDriven = False on each subtask's Task object. Set Type = pjFixedDuration as well if every iteration must use fixed-duration scheduling.

Why does a subtask start later than the selected Monday?

Check the project and task calendars, working hours, and task constraints in Microsoft Project. A nonworking date or time can move the scheduled start.

Can WPS Office run the Microsoft Project VBA procedure?

No. The procedure uses Microsoft Project's task and scheduling object model. WPS Spreadsheets can maintain a separate tabular tracker, but it does not replace that Project automation.