identifying if any task in a block is linked to tasks outside the block

Home Forums Microsoft Project Discussion Forum identifying if any task in a block is linked to tasks outside the block

Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #535606

      I have an existing project plan that someone has copied and updated a section of. I now need to copy that block (which has been extensively changed) back into the live plan. Obviously, this is simple to do however, a few of the tasks are linked to items outside the block which will be copied in.
      As an example, the section of the plan will be copied in existing tasks 100-200. A few of these tasks are linked to either <100 or >200.
      After I have copied the block in, I will manually add these few links in however, finding them is tricky.
      I can’t use the “is within” filter as this only finds single links; for instance, if task 150 is driven by 90, it will not find task 150 if it is driven by 90,110.

      Does anyone have any solutions to this?

      Thanks

      Miles

    • #535609

      I solved it, so I thought I would share it here 🙂 Using VBA and marking the tasks (so you need to set task formatting for marked tasks to see the results):

      Sub find_links_outside_block()
      'Produce by Miles Goodchld 26th Aug 2022
      
      Dim t As Task
      Dim T_pred As Task
      Dim T_succ As Task
      Dim Block_start As Integer
      Dim Block_end As Integer
      Dim Choice As Integer
      
      Block_start = 15
      Block_end = 23
      Choice = 3  '1 = predecessor only, 2=successort only, 3 = both2
      
      Block_start = InputBox("enter the row number of the start of your block", "finding links outside a block of tasks")
      Block_end = InputBox("enter the row number of the end of your block", "finding links outside a block of tasks")
      Choice = InputBox("Select what you want to hightlight:" & vbCrLf & "1 = Only Predesessors" & vbCrLf & "2 = Only Successors" & vbCrLf & "3 = Both", "finding links outside a bloxk of tasks")
      
      For Each t In ActiveProject.Tasks
          If Not t Is Nothing Then
          t.Marked = False
              If t.ID >= Block_start And t.ID <= Block_end Then
                  If Choice = 1 Or Choice = 3 Then
                  For Each T_pred In t.PredecessorTasks
                      If T_pred.ID < Block_start Or T_pred.ID > Block_end Then t.Marked = True
                  Next T_pred
                  End If
                  If Choice = 2 Or Choice = 3 Then
                  For Each T_succ In t.SuccessorTasks
                      If T_succ.ID < Block_start Or T_succ.ID > Block_end Then t.Marked = True
                  Next T_succ
                  End If
              Else
                  'do nothing as outside the block
              End If
          Else
              'do nothing as T is nothing
          End If
      
      Next t
Viewing 1 reply thread
  • You must be logged in to reply to this topic.