logo
search
Others

VBA Macro to Find a Task by Unique ID in Microsoft Project

Anum MushtaqAnum Mushtaq Oct 13, 2026 869 views

Question details

The user needs a reliable way to locate specific tasks in Microsoft Project, as standard task IDs can change. A VBA macro is requested to prompt for a Unique ID and locate the corresponding task.

How to Find a Task by Unique ID Using a VBA Macro in Microsoft Project
Product
Microsoft Project
Device & OS
not provided
Scenario
Locating a specific task within a dynamic project schedule where standard row IDs frequently change.
Observed behavior
Because standard Task IDs shift when tasks are rearranged, the user needs a custom script to automate the Find command for permanent Unique IDs.
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 Find Unique ID Macro

Use this custom VBA macro to prompt for a Unique ID and automatically select the matching task in your project schedule.

Because standard Task IDs change when a schedule is modified, using the Unique ID is the most reliable way to locate a specific task. This macro automates the built-in Find command, bypassing the limitations of the default Go To dialog.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in Microsoft Project.

2
Insert a New Module

In the VBA editor, click on 'Insert' in the top menu bar and select 'Module'.

3
Paste the Macro Code

Copy and paste the following code into the module window: Sub EmulateGoTo() Dim FindID As String FindID = InputBox("Enter unique ID") If FindID <> "" Then Find Field:="Unique ID", Test:="equals", Value:=CSng(FindID) End If End Sub

4
Run the Macro

Press F5 or click 'Run' > 'Run Sub/UserForm' from the menu. An input box will appear asking you to enter the Unique ID you wish to find.

Create and Run a Find Unique ID Macro
Macro Execution: Once the Unique ID is entered, Microsoft Project will automatically jump to and highlight the corresponding task in your view.
Free Microsoft Office alternative

Manage Project Schedules with WPS Office

While Microsoft Project is built for complex scheduling, WPS Office provides a free, lightweight, and versatile alternative for managing everyday projects. Use WPS Spreadsheet's powerful templates and formulas to track tasks easily without needing VBA macros.

Free and lightweight suite for daily task trackingSeamless compatibility with Microsoft Office formats (XLSX, DOCX, PPTX)Familiar, tabbed user interface for quick adoptionRich library of free project management templates
microsoft office alternative - wps office

Frequently Asked Questions

What is the difference between a Task ID and a Unique ID in Microsoft Project?

A Task ID represents the current row number of a task and will change if you move, delete, or insert tasks above it. A Unique ID is a permanent number assigned when the task is first created and never changes throughout the project's lifecycle.

How do I show the Unique ID column in my Microsoft Project view?

Right-click on the header of any existing column (such as Task Name), select 'Insert Column', type 'Unique ID', and hit Enter to add it to your current view.

Can I assign a keyboard shortcut to this VBA macro?

Yes. In Microsoft Project, go to the View tab, click Macros > View Macros, select your newly created macro, click 'Options', and assign a shortcut key combination for quick access.