VBA & Macro Problems

How to Sum Selected Cells in Microsoft Project Using a VBA Macro

Emma BrownEmma Brown Nov 3, 2026 869 views

Question details

The user needs to calculate the total sum of specific selected numeric fields in Microsoft Project.

How to Sum Selected Cells in Microsoft Project Using a VBA Macro
Product
Microsoft Project
Device & OS
not provided
Scenario
The user selects multiple numeric cells across different tasks with the mouse and needs to see their total sum.
Observed behavior
Microsoft Project does not provide a status bar sum indicator for selected numeric fields like Excel does, requiring a custom script to calculate the total.
Before you start

Ensure you have the Developer tab enabled in Microsoft Project so you can access the Visual Basic for Applications (VBA) editor.

Solution 1Recommended

Create and Run a Custom VBA Macro to Sum Cells

Use a custom VBA script to iterate through your selected tasks and fields, calculate the total sum, and display it in a message box.

Since Microsoft Project is fundamentally a scheduling tool, it lacks quick spreadsheet-like calculation features on the status bar. Implementing a VBA macro is the most direct way to sum cells you select with your mouse.

1
Open the VBA Editor

In Microsoft Project, navigate to the Developer tab or View tab, click on 'Macros', and select 'Visual Basic' to open the VBA Editor.

2
Insert a New Module

In the VBA Editor, click 'Insert' from the top menu and select 'Module' to create a blank workspace for your code.

3
Paste the Macro Code

Copy and paste the following code into the module window: Sub SumSelected() Dim t As Task Dim Fld As Variant Dim NumSum As Single For Each t In ActiveSelection.Tasks For Each Fld In ActiveSelection.FieldIDList NumSum = NumSum + t.GetField(FieldID:=Fld) Next Fld Next t MsgBox "Selected Sum = " & NumSum End Sub

4
Select Numeric Cells

Close the VBA editor and return to your project view. Use your mouse to click and drag, or hold the 'Ctrl' key to select the specific numeric cells you want to sum.

5
Run the Macro

Go to 'Macros' > 'View Macros', select 'SumSelected' from the list, and click 'Run'. A pop-up message box will appear displaying the calculated total.

Create and Run a Custom VBA Macro to Sum Cells
Macro Security: You may need to adjust your macro security settings in the Trust Center (File > Options > Trust Center) to allow custom macros to run.
Free Microsoft Office alternative

Manage Your Data Easily with WPS Office

While Microsoft Project requires custom macros for simple summations, a dedicated spreadsheet tool is often better for data calculations. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office. With WPS Spreadsheet, you can instantly see the sum of selected cells in the status bar—no VBA required—and it perfectly supports Microsoft Excel formats.

  1. 1. Download and Install: Visit the official WPS Office website to download the free installation package for your operating system.
  2. 2. Open WPS Spreadsheet: Launch WPS Office and click on 'Spreadsheet' to open a new or existing workbook.
  3. 3. Calculate Instantly: Select any numeric cells and instantly view the sum at the bottom-right corner of your screen without writing any code.
Instantly view the sum, average, and count of selected cells in the built-in status bar.Fully compatible with Microsoft Excel (.xlsx) and other Office formats.Lightweight architecture that runs smoothly on Windows, Mac, and Linux.Advanced VBA support available for complex automation tasks.Familiar, easy-to-use interface ensuring seamless migration.
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't Microsoft Project show the sum of selected cells at the bottom of the screen?

Unlike Excel, Microsoft Project is designed primarily for task scheduling and timeline management rather than flexible data calculation. It focuses on rolling up project costs and durations automatically, so it lacks the quick, arbitrary status bar calculation features found in spreadsheet software.

Can I assign a keyboard shortcut to the sum macro in MS Project?

Yes. After creating the macro, go to the Macros dialog box (View > Macros), select your 'SumSelected' macro, click 'Options', and assign a custom keyboard shortcut for faster access.

Does this VBA macro work for non-numeric fields?

No, the provided VBA macro uses mathematical addition (NumSum + value). If you select text or date fields, the macro will fail or return an error. Always ensure that only numeric fields are selected before running the macro.

How do I select multiple specific cells in Microsoft Project before running the macro?

You can hold down the 'Ctrl' key on your keyboard while clicking on different numeric cells in your task list. This allows you to select multiple non-adjacent fields to be summed up by the macro.