Recurring task to start on a certain day. Delay Problems RRS feed

  • Question

  • Hi,

    Is there a way you can insert lag time but ensure that the next task will only start on the next available day of either a Monday or a Friday. currently i am having to manually change the dates of a recurring task if i am delayed in the processes running up to the task. so if the task previous was finishing on a Sunday, the task next would start that next day on a Monday. Though if the task was delayed a day it would obviously run into Monday meaning the next task could not start till the Friday. The task in question needs to be done Monday and Friday so adding lags just pushes the dates out and i have to manually remedy this which is time consuming. 

    Any help is greatly appreciated

    Tuesday, December 2, 2014 3:15 PM

All replies

  • Leep18,

    There are a couple of ways to insure a task starts on a particular day, and you're right, using lag time is not a good way.

    The first way is to set up a custom calendar that has only Monday and Friday as work days. Then set up a one minute duration task that is the successor of the driving task and assign the custom calendar to the one minute task. Use the one minute task as the predecessor to the task that can only start on Monday or Friday. The one minute task will control the timing (i.e. Monday or Friday start) but once the one minute task is "triggered" it will set the start of the next task, which once started, will continue through completion. The disadvantage of this approach is that the successor task will start at 8:01 AM instead of the default 8:00 AM.

    The second way to do this is with VBA. The following macro will insure a successor task, marked by setting the Flag1 field,  always starts on the next Monday or Friday at the beginning of a work day.

    'This macro ensures all selected tasks can only be started on a Monday or Friday
    '   at the default project start time
    '   Tasks are selected by setting Flag1. Note: this procedure does leave a
    '   start-no-earlier-than constraint on all shifted tasks
    'written by John 12/2/134 7:00 pm
    Dim t As Task
    Dim EndTime As String, StartTime As String, ProjCal As String
    Dim WkD As Integer, DOffest As Integer
    Dim OFlag As Boolean
    Dim DayDate As Date
    Sub NextDayB()
    'cycle through each task
    ProjCal = ActiveProject.Calendar
    For Each t In ActiveProject.Tasks
        'skip over blank lines
        If Not t Is Nothing Then
            'only look at Start time of non-summary tasks
            If t.Summary = False And t.Flag1 = True Then
                'find default start and end times for this task
                OFlag = False
                WkD = Weekday(t.Start)
                'determine the default start time for this project
                StartTime = ActiveProject.BaseCalendars(ProjCal).WeekDays(WkD).Shift1.Start
                'determine required shift in start time based on current start
                If WkD = 4 Or WkD = 7 Then DOffset = 2: OFlag = True
                If WkD = 5 Or WkD = 11 Then DOffset = 1: OFlag = True
                If WkD = 3 Or (6 And (Hour(t.Start) <> Hour(StartTime))) Then DOffset = 3: OFlag = True
                If WkD = 2 And (Hour(t.Start) <> Hour(StartTime)) Then DOffset = 4: OFlag = True
                'shift the task start to the next Monday or Friday at the default start time
                If OFlag = True Then t.Start = DateValue(DateAdd("d", DOffset, t.Start)) & " " & StartTime
            End If
        End If
    Next t
    End Sub

    Hope this helps.


    • Edited by John - Project Wednesday, December 3, 2014 2:43 AM tweaked code
    Tuesday, December 2, 2014 4:03 PM