Solved

Missing Task ids in Gantt

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Article by: x-men
Where used to see Gantt charts for illustrating project timelines, but what if I wanted to visualize passed timed events? Here's how.
"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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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