Solved

Missing Task ids in Gantt

Posted on 2008-06-25
3
547 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

910 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

18 Experts available now in Live!

Get 1:1 Help Now