Hi All
I have never used VB before but have this Macro that I need to try and amend. I wonder whether anyone would be so kind in assisting me, I am not even sure this is the correct place.
The script is below, What I would like it to do is if the text4, text5 and text6 fields are empty then run the macro, if they are not empty ignore the script and move onto the next empty task field and populate with the next sequential number.
Many Thanks
Dave
Sub SetFields()
' You MUST EDIT the next three lines before running this macro
Const sncProject = "PRJ0010009"
Const sncTaskNumPrefix = "PRJTASK"
Const sncTaskNumBase = 10000
Dim t As Task
Dim pred As Task
Dim order As Integer
For Each t In ActiveProject.Tasks
t.SetField pjTaskText4, sncProject
t.SetField pjTaskText7, "Pending"
t.SetField pjTaskText5, sncTaskNumPrefix & Format(sncTaskNumBase + t.ID, "00000")
If t.OutlineLevel > 1 Then
t.SetField pjTaskText6, t.OutlineParent.Text5
Else
t.SetField pjTaskText6, sncProject
End If
order = 0
t.SetField pjTaskMarked, "No"
For Each pred In t.PredecessorTasks
If pred.OutlineParent <> t.OutlineParent Then
' Only sibling dependencies can be imported into SNC.
' Flag this row as a problem and ignore the dependency.
t.SetField pjTaskMarked, "Yes"
Else
If pred.Number7 > order Then
order = pred.Number7
End If
End If
Next pred
t.SetField pjTaskNumber7, order + 10
Next t
End Sub