Find UID Utility

Hey folks…sorry for being gone so long.  Been a bit busy managing the schedule for an ERP cutover.  Figured I’d post a little VBA utility that I wrote to help navigate the schedule.

As many of you probably know, it’s best practice to expose and use the Unique ID field within the schedule.  The Unique ID field doesn’t change – unlike the ID field which will recalculate to reflect any new tasks added.

In this case, with a couple thousand items, it got hard to find a specific UID.  So, I wrote a quick macro to automate the process.

This macro will navigate to a specific UID within the schedule.  It also will post the UID of original task that you’re on when you run it to the Number10 field.

Sub FindUID()

    Dim T As Task
    Dim Temp_UID As Integer
    Dim UID As Integer
    Dim ID As Integer
    
    ActiveProject.ProjectSummaryTask.Number10 = Application.ActiveSelection.Tasks.Item(1).UniqueID
    
    UID = InputBox("Enter UID", "UID")
    ID = 1
    
    ActiveProject.AutoFilter = False
    
    For Each T In ActiveProject.Tasks
        Temp_UID = T.UniqueID
        If Temp_UID = UID Then
            ID = T.ID
        End If
        Debug.Print T.UniqueID
    Next T
    
    If ID <> 1 Then
        SelectRow row:=ID, RowRelative:=False
    Else
        MsgBox "UID Not Found", vbOKOnly, "Error"
    End If
    
    ActiveProject.AutoFilter = True
    OutlineShowAllTasks
    
End Sub

The following macro is essentially the same, but will pick up the number in Number10 and return to that row.

Sub GoBacktoUID()

    Dim T As Task
    Dim Temp_UID As Integer
    Dim UID As Integer
    Dim ID As Integer

    ID = 1
    
    ActiveProject.AutoFilter = False
    
    For Each T In ActiveProject.Tasks
        Temp_UID = T.UniqueID
        If Temp_UID = ActiveProject.ProjectSummaryTask.Number10 Then
            ID = T.ID
        End If
        Debug.Print T.UniqueID
    Next T
    
    If ID <> 1 Then
        SelectRow row:=ID, RowRelative:=False
    Else
        MsgBox "UID Not Found", vbOKOnly, "Error"
    End If
    
    ActiveProject.AutoFilter = True
    OutlineShowAllTasks
    
End Sub

Assign these macros to two key strokes and you’ll be easily able to navigate a large project with ease.

Advertisements
Find UID Utility

6 thoughts on “Find UID Utility

  1. Joel halprin says:

    Andrew – HI. I’ve used this on past schedules, after showing that UIDs are the way to go, and it is great. Problem is installing either on on a new MSP 210 project. Why is Number10 used. as it has no data in it? Thanks in afvance

  2. Number10 is just a field to capture the original UID to navigate back to it. I just picked that because nobody ever really uses it. (The item is stored at the project summary task level, as I recall). For new projects, I would deploy this either through Project Server or using the Global.MPT file on your laptop…..it should apply to any new project you would open on the laptop.

  3. John Acello says:

    Hi Andrew
    I have been using your FindUID macro for some time. I now have an issue where in one project file I get an error 91 “object variable or With block variable not set”. Others are fine. The module containing the macro in global.MPT. The line flagged is “Temp_UID = T.UniqueID”.

    Any ideas on what the issue might be?

    Thanks
    John

    1. Not entirely sure….maybe there’s a blank line or it’s choking on an inactive task? Can’t remember how much error handling I put in to it.

      Also try removing all filters (F3) before running.

  4. John says:

    I have been using this and the macro proves to be extremely handy. Thanks. However, I find that it does not work on all views, returning either to the wrong row or flagging an error. What would cause this behavior or make it view dependent. All are basically gantt type views.

    Regards

    1. Maybe if there’s a filter applied? I think it just counts from the top. If there’s a filter or grouping, that may throw things off. (I may not have added logic to remove the filter on the return one….or it’s not counting the right row in the first place)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s