Solved

Missing Task ids in Gantt

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

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…
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

831 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