Forum Discussion
Why Does Project Change the Order of Task IDs in the Predecessor Column
- Jul 26, 2022
As I recall the "re-ordering" done by Project has to do with the sequence that tasks were created, or something similar. But your question of whether it is a big deal has a simple answer, the order doesn't affect anything (i.e. no big deal).
However as it turns out I actually wrote a macro to re-order the Predecessor field a few years ago in response to another user's consternation about the non-sequential order.
John
'Rev A - modified code to replace existing predecessors with numerically sorted predecessors
' Do not need to worry about successors, they automatically get sorted with predecessors
'Macro written by John - Project
Private str() As String
Private t As Task
Private TstStr As String, TempStr As String
Private i As Integer, j As Integer, k As Integer, NumTsk As Integer
Private lnktyp As Long
Sub sequential_PredsSucc()NumTsk = ActiveProject.Tasks.count
ReDim str(NumTsk)
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.Predecessors <> "" Then
TstStr = t.Predecessors
lnktyp = pjTaskPredecessors
ArrayBldAndSort TstStr, lnktyp
End If
End If
Next t
MsgBox "Pred/Succ sorting complete", vbInformation
End Sub
'this routine builds a single dimensional array of predecessor
' and/or successor data, sorts the array(s) in
' numerical order and finally dumps it as a delimited string into
' extra task field Text1 (Preds) and/or Text2 (Succs)
' Rev A - does not use Text1 and Text2, sorted preds replace existing preds.
Private Sub ArrayBldAndSort(TstStr, lnktyp)
i = 1
While InStr(TstStr, ",") > 0
str(i) = Mid(TstStr, 1, InStr(TstStr, ",") - 1)
TstStr = Mid(TstStr, InStr(TstStr, ",") + 1)
i = i + 1
Wend
str(i) = TstStr
'sort the array that was just built
For j = 1 To i - 1
For k = j + 1 To i
If str(j) > str(k) Then
TempStr = str(j)
str(j) = str(k)
str(k) = TempStr
End If
Next k
Next j
t.SetField lnktyp, ""
t.SetField lnktyp, str(1)
If i > 1 Then
For j = 2 To i
t.SetField lnktyp, t.GetField(lnktyp) & "," & str(j)
Next j
End If
End Sub
As I recall the "re-ordering" done by Project has to do with the sequence that tasks were created, or something similar. But your question of whether it is a big deal has a simple answer, the order doesn't affect anything (i.e. no big deal).
However as it turns out I actually wrote a macro to re-order the Predecessor field a few years ago in response to another user's consternation about the non-sequential order.
John
'Rev A - modified code to replace existing predecessors with numerically sorted predecessors
' Do not need to worry about successors, they automatically get sorted with predecessors
'Macro written by John - Project
Private str() As String
Private t As Task
Private TstStr As String, TempStr As String
Private i As Integer, j As Integer, k As Integer, NumTsk As Integer
Private lnktyp As Long
Sub sequential_PredsSucc()
NumTsk = ActiveProject.Tasks.count
ReDim str(NumTsk)
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.Predecessors <> "" Then
TstStr = t.Predecessors
lnktyp = pjTaskPredecessors
ArrayBldAndSort TstStr, lnktyp
End If
End If
Next t
MsgBox "Pred/Succ sorting complete", vbInformation
End Sub
'this routine builds a single dimensional array of predecessor
' and/or successor data, sorts the array(s) in
' numerical order and finally dumps it as a delimited string into
' extra task field Text1 (Preds) and/or Text2 (Succs)
' Rev A - does not use Text1 and Text2, sorted preds replace existing preds.
Private Sub ArrayBldAndSort(TstStr, lnktyp)
i = 1
While InStr(TstStr, ",") > 0
str(i) = Mid(TstStr, 1, InStr(TstStr, ",") - 1)
TstStr = Mid(TstStr, InStr(TstStr, ",") + 1)
i = i + 1
Wend
str(i) = TstStr
'sort the array that was just built
For j = 1 To i - 1
For k = j + 1 To i
If str(j) > str(k) Then
TempStr = str(j)
str(j) = str(k)
str(k) = TempStr
End If
Next k
Next j
t.SetField lnktyp, ""
t.SetField lnktyp, str(1)
If i > 1 Then
For j = 2 To i
t.SetField lnktyp, t.GetField(lnktyp) & "," & str(j)
Next j
End If
End Sub