Create a Summary Task and Linked Subtasks in Microsoft Project with VBA
Question details
Create a summary task and up to 20 linked subtasks using 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.
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.
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.
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.
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.
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.
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.
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.

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.

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.




