?
Solved

Missing Task ids in Gantt

Posted on 2008-06-25
3
Medium Priority
?
592 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
Thomas_Vanparys earned 1000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

777 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