Solved

Missing Task ids in Gantt

Posted on 2008-06-25
3
533 Views
Last Modified: 2013-11-15
Over a period of time I have moved, deleted and inserted tasks in my project and now find that the sequence of the task ids are not contiguous e.g. the task numbers jump from 10 to 12 or 202 to 206.
I have tried sorting on task id with the renumber option but it made no difference. (I have no external tasks)
The numbers are not a problem in themselves but this affects a macro I have which goes through the tasks colouring a status field depending on it's value.
As soon as the macro hits a gap in the numbering it colours the next line based on the value in the current line
This is the macro in case anyone can see a way around this
Sub Colour()
For Each tskT In ActiveProject.Tasks
    If Not (tskT Is Nothing) Then
    Select Case tskT.Text1
        Case "In Progress"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjBlue
            Font Bold:=False
           
        Case "Started"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjBlue
            Font Bold:=False
           
        Case "Cancelled"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjGreen
            Font Bold:=True
       
        Case "On Hold"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjGreen
            Font Bold:=True
           
        Case "Complete"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjGreen
            Font Bold:=True
           
         Case "Approved"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjGreen
            Font Bold:=True
           
        Case "Not Started"
            SelectTaskField Row:=tskT.ID, RowRelative:=False, Column:="Text1"
            Font Color:=pjRed
            Font Bold:=False
       
        Case Else
        SelectRow Row:=tskT.ID, RowRelative:=False
    End Select
    End If
Next tskT
End Sub


0
Comment
Question by:sbesley
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
Thomas_Vanparys earned 250 total points
ID: 21908112
Hi sBesley,

The macro is dependent on the state of your view. I don't think it's actually an issue with ID's.

It should work if your view:
- Has no filters (Project > Filtered For > All Tasks)
- Has no Grouping (Project > Group by > No Group
- Shows summary tasks (Tools > Options > View > Show Summary Tasks)
- Has no collapsed outlines (Project > Outline > Show > All Subtasks)
- Is sorted on ID (Project > Sort > By ID)

If after this the macro still fails, it may be because the "For Each tskT In ActiveProject.Tasks" loop does not go through the tasks in the order you might expect. (ie not based on incrementing the ID in ascending order). It that's indeed the case then might want to change the way you deal with the 'For ... Next' loop entirely and do it based on what you have on the screen.

To do this, first determine how many tasks there are on screen. Since there is no 'Rows' collection the next best thing - given the above view constraints - is "ActiveProject.Tasks.Count". Once you have that number you can loop through all the rows by incrementing a counter.
The next thing to solve is how you deal with the 'Select Case' since you can no longer refer to 'tskT.Text1' as the source of your decision. Instead you can set your active cell using something like SelectTaskCell(Row, Column, RowRelative)' and then use the 'ActiveCell.Text' to drive your 'Select Case'
   
I hope this helps.
Thomas Vanparys, PMP
 
0
 

Author Closing Comment

by:sbesley
ID: 31470595
Excellent thanks - I had a filter on one of the columns which was hiding blank lines (not sure why but that's a question for another day). Important thing is that now I "filter all" the macro works
0
 

Author Comment

by:sbesley
ID: 21908561
I had  filter on which was hiding blank lines - when this filter was removed the numbering of the ids was fine and the macro worked - Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

At the office, we’ve started to get serious about organizing what we’re doing. I mean, it was getting to the point where every time I received a phone call, it began with “I know you’re really busy, but…” My boss was taking tasks away from me left a…
Re-planning is just as important as planning. MS Project files need to be updated regularly to reflect the current status of the project and to streamline the upcoming tasks. We have seen a lot of issues where project managers have not updated the p…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now