none
setting conditional rules to start or finish time of the tasks in MS project?

    Question

  • Hello all

    I attached the file that I working on ,

    In my structural project  I have set a calendar that in which working days start at 07:00 AM and end at 06:00 PM except Fridays which are off days every 2 weeks ( one friday working day and one friday off day ) also working time of the working Friday starts from 08:00 AM and end at 05:00 PM ( less and not as standart days) .. All tasks are linked automatically 

    When I copy multiple tasks and past them to reproduce tasks ( for other buildings) and when try to adjust the hours time of a task normally all the task linked  being effected  and automatically shifting to other finishing times such as the working finish time being 09:00 oclock AM not 06:00 or 05:00 PM but I want all summary tasks to start at 07:00 or 08:00 AM and All finish aslo at 06:00 or 05:00 PM so my question is : Can I make a rule ( function , macro, VBA etc) to control the finish times of the tasks and adjust them ( or its durations ) automatically not manually ?? when they shifted to another or not desired hours

    ( sorry for my poor english I hope that I stated my problem)

    Thanks in advance .. I wish I can find a solution for this problem by your valuable helps ..

    https://drive.google.com/open?id=1K_YwxUJj6hXE2C1dYwnxIGZ32sLTjGN7 


    Adnan Hamza

    Wednesday, May 8, 2019 3:44 PM

Answers

  • adnhmz,

    You're welcome and thanks for the feedback.

    Project is neither easy to learn nor is it intuitive, so don't apologize for being a beginner, we all were at one time.

    Once you create a custom calendar and make it the Project calendar, all tasks and resources will follow that calendar. Therefore you have already established your workdays and times for all tasks. The only time you need a task calendar is if a particular task's calendar needs to differ from the Project calendar, and in your case, that is not true. I saw you do not have resources in your file, but if you do add resources and one or more resources has unique working times that are different from the Project calendar, then you create a custom resource calendar and assign it to the resource via the Base Calendar filed on the Resource Sheet.

    If you manually enter a start or finish date for any task, Project will automatically set a constraint of "start no earlier than", if a start date is manually entered, or "finish no earlier than", if a finish date is manually entered. I'm guessing that's how you ended up with the constraints I saw and if you use copy and paste, those constraints will also be copied.

    Part of the issue you are running into is because you use copy and paste so if you continue to use that process for creating your tasks, you will need to manually review all task groups and adjust as necessary to avoid odd finish times.

    As I mentioned I've written several macro to adjust tasks such that they only occur during certain times. For example, you may not want to start a painting job toward the end of a day or don't want to start a full day task that must run complete from start to finish in a single day.

    Below is one of the macros I wrote. It may not meet your needs exactly but should be easy to modify.

    Hope this helps.

    John

    'This macro ensures all selected tasks can only be started if they can be
    '   completed the same day
    '   Tasks are selected by setting Flag1. Note: this procedure does leave a
    '   start-no-earlier-than constraint on all shifted tasks
    'written by John-Project 4/27/18 1:30 pm
    Option Explicit
    Option Compare Text
    Sub NextMonOrFri()
    Dim t As Task
    Dim StartTime As String

    ProjCal = ActiveProject.Calendar
    'determine the default start time for this project
    StartTime = ActiveProject.BaseCalendars(ProjCal).WeekDays(WkD).Shift1.Start
    'cycle through each task to find flagged tasks
    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
                'determine if start and finish are currently on the same day
                '   if not, move start to next working day
                If Day(t.Start) <> Day(t.Finish) Then
                    t.Start = DateValue(DateAdd("d", 1, t.Start)) & " " & StartTime
                End If
            End If
        End If
    Next t
    End Sub

    • Marked as answer by adnhmz Wednesday, May 8, 2019 11:23 PM
    Wednesday, May 8, 2019 9:15 PM

All replies

  • adnhmz,

    I took a quick look at your file and I notice a couple of things.

    Since your Project calendar (KBP) already reflects the workweek pattern you describe above, all tasks will by default follow that calendar, you do not need to set a separate Task Calendar for any tasks.

    Project only allows one definition for a day and you have that set at 10h, which is fine for Saturday through Thursday but doesn't work for Friday since, when it is a working day, it is only 8h. However, you have entered all durations in hours and that is what you should do.

    Several tasks have a "start no earlier than" constraint, including the first task in your plan. You do not need, nor want, any constraints in your schedule, you have a logically linked structure (i.e. all tasks have predecessors and successors).

    I suggest you eliminate all task calendars and leave them as "none". Also remove all constraints (i.e. all tasks should be "as soon as possible".

    Now to answer your question. Looking at task 2055, it indeed shows a 9:00AM finish time. That is because the predecessor task (2054), which is a 10h task, starts at 1:00PM on a 10h workday (Thurs) but finishes on an 8h day so it's finish time is 2:00PM. Task 2055, which is a 5h task, starts at 2:00PM on an 8h day, so it can't finish by 5:00PM and spills over to the next day for a finish at 9:00AM.

    How do you fix that? There are basically three ways. One is to go through the plan and manually shift tasks as necessary so everything finishes at 5:00PM or 6:00PM. A second method is to add a bunch of zero duration milestones on a custom calendar that only has every other Friday as a workday and use those milestones to adjust tasks that might "spill over". A third method is with a VBA macro that looks at all tasks in the plan and adjusts tasks as necessary to insure all finish times are either 5:00PM or 6:00PM. I've used the VBA approach for different scenarios.

    Hope this helps.

    John
    • Edited by John - Project Wednesday, May 8, 2019 4:11 PM sentence form
    Wednesday, May 8, 2019 4:08 PM
  • Thank you very much John for taking time and examine my file .. this is kindness

    1. Regarding your notes I will try to test all it on my file one by one and also in the next schedules , also I am a       beginner in MS Project so these recommendation are useful for me and I thing these are a part of the solution.

    2. Just I want to replay to ( eliminate all task calendars and leave them as "none". If do that how can I control the calendar days that I want to plan ( i.e. Fridays working days and weekdayd to be start on non standart time start ( 08:00 in default calendar). The constraints have been added automatically in the beginning of plan and been copied and pasted each time after. 

    3. As you illustrated it is normally all tasks spills over to next days when the pasted tasks comes on not the same days that copied from so what I do is the first way that you stated ( manually adjusting all ) but this taking time and I hope I will find the VBA code or some Project addin 3rd. party tools to do this  but  I am new in this field so I will try and try to find the best solution after I will write it here in this form to make use of by others also.

    If you can write the right vba code for will be  appreciated.

    thank you . 


    Adnan Hamza

    Wednesday, May 8, 2019 8:25 PM
  • adnhmz,

    You're welcome and thanks for the feedback.

    Project is neither easy to learn nor is it intuitive, so don't apologize for being a beginner, we all were at one time.

    Once you create a custom calendar and make it the Project calendar, all tasks and resources will follow that calendar. Therefore you have already established your workdays and times for all tasks. The only time you need a task calendar is if a particular task's calendar needs to differ from the Project calendar, and in your case, that is not true. I saw you do not have resources in your file, but if you do add resources and one or more resources has unique working times that are different from the Project calendar, then you create a custom resource calendar and assign it to the resource via the Base Calendar filed on the Resource Sheet.

    If you manually enter a start or finish date for any task, Project will automatically set a constraint of "start no earlier than", if a start date is manually entered, or "finish no earlier than", if a finish date is manually entered. I'm guessing that's how you ended up with the constraints I saw and if you use copy and paste, those constraints will also be copied.

    Part of the issue you are running into is because you use copy and paste so if you continue to use that process for creating your tasks, you will need to manually review all task groups and adjust as necessary to avoid odd finish times.

    As I mentioned I've written several macro to adjust tasks such that they only occur during certain times. For example, you may not want to start a painting job toward the end of a day or don't want to start a full day task that must run complete from start to finish in a single day.

    Below is one of the macros I wrote. It may not meet your needs exactly but should be easy to modify.

    Hope this helps.

    John

    'This macro ensures all selected tasks can only be started if they can be
    '   completed the same day
    '   Tasks are selected by setting Flag1. Note: this procedure does leave a
    '   start-no-earlier-than constraint on all shifted tasks
    'written by John-Project 4/27/18 1:30 pm
    Option Explicit
    Option Compare Text
    Sub NextMonOrFri()
    Dim t As Task
    Dim StartTime As String

    ProjCal = ActiveProject.Calendar
    'determine the default start time for this project
    StartTime = ActiveProject.BaseCalendars(ProjCal).WeekDays(WkD).Shift1.Start
    'cycle through each task to find flagged tasks
    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
                'determine if start and finish are currently on the same day
                '   if not, move start to next working day
                If Day(t.Start) <> Day(t.Finish) Then
                    t.Start = DateValue(DateAdd("d", 1, t.Start)) & " " & StartTime
                End If
            End If
        End If
    Next t
    End Sub

    • Marked as answer by adnhmz Wednesday, May 8, 2019 11:23 PM
    Wednesday, May 8, 2019 9:15 PM
  • Thank you very much for your encouraging and for your time John ,

    Yes I yet did'nt assign resources to the project so my first goal is to determine the probable deadline of the project 

    I have 64 building will be poured concrete by 6 sets of tunnel forms. I will do that in the next step. and will follow all your recommendations. But I have no other option beyond the (copy and paste) technique so as you see I have huge similar tasks that just differ from each other by names and the routine of recycling the 6 sets of formwork. So the only solution as I quess is to writing a code based on yours (or modifying it) .. and I will learn it.  

    Thank you again sir, 


    Adnan Hamza

    Wednesday, May 8, 2019 10:37 PM
  • Adnan,

    You're welcome and thanks for the feedback. If I answered your question, please consider marking one of my responses as the answer.

    If you want a good book on Project VBA, I recommend Rod Gill's book. You can find out more at:

    http://www.project-systems.co.nz/project-vba-book

    John

    Wednesday, May 8, 2019 11:17 PM
  • thank you very much..

    Adnan Hamza

    Thursday, May 9, 2019 12:16 AM