VBA Macro to Find a Task by Unique ID in Microsoft Project
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.

- 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.
Ensure you have the Developer tab enabled in Microsoft Project so you can access the Visual Basic for Applications (VBA) editor.
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.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in Microsoft Project.
In the VBA editor, click on 'Insert' in the top menu bar and select 'Module'.
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
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.

Use the Built-in Go To Dialog
If you prefer not to use VBA and know your current standard Task IDs, you can manually jump to tasks using the Go To shortcut.
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.

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.




