Consulting

Results 1 to 5 of 5

Thread: code for near critical activities !!

  1. #1

    Smile code for near critical activities !!

    Guys

    What I want is to use a flag field with a code to set Yes to activities with total float bigger than one but less than 4. I have tried the IF then statement but cannot seem to get the range bit. I can do one or the other but not the between bit. Any help would be really appreciated.

    Andrew

  2. #2
    VBAX Newbie
    Joined
    Sep 2011
    Posts
    2
    Location

    Exclamation Near Critical

    I have tried to write a code for the same using "ActiveProject.Tasks.Item(Current_Record).StartSlack" to read the "Start Slak Field" value.
    It seems that ".StartSlak" return the "Start Slak Filed" multiplied by some value. So, ".StartSlak" does not match "Start Slak Field".

    I used my code with some templates and all .StarSlak were multiplied by 480 !! Which is the "ActiveProject.Tasks.Item(Current_Record).Duration"

    So, to read the correct "Start Slak Field" you should use " ActiveProject.Tasks.Item(Current_Record).StartSlack / ActiveProject.Tasks.Item(Current_Record).Duration " to read the correct value

    Last edited by magdi; 09-22-2011 at 12:14 AM.

  3. #3
    VBAX Newbie
    Joined
    Sep 2011
    Posts
    2
    Location
    My Code using Hoursperweek * Hoursperday

    [VBA]Option Explicit
    ' Constants
    Const Lower_Range_Start_Slak = 1
    Const Higher_Range_Start_Slak = 4
    Sub Create_Near_Critical()
    Dim Current_Record As Integer
    ' Loop for all record to check the Start Slak if it within the defined range
    On Error Resume Next

    While Current_Record < ActiveProject.Tasks.Count

    Current_Record = Current_Record + 1

    ActiveProject.Tasks.Item(Current_Record).Flag1 = False

    If (ActiveProject.Tasks.Item(Current_Record).StartSlack <= Higher_Range_Start_Slak * ActiveProject.HoursPerDay * ActiveProject.HoursPerWeek) And _
    (ActiveProject.Tasks.Item(Current_Record).StartSlack >= Lower_Range_Start_Slak * ActiveProject.HoursPerDay * ActiveProject.HoursPerWeek) Then

    ActiveProject.Tasks.Item(Current_Record).Flag1 = True
    End If

    Wend
    End Sub[/VBA]

  4. #4
    VBAX Regular
    Joined
    Feb 2011
    Posts
    13
    Location
    Quote Originally Posted by armchairandy
    Guys

    What I want is to use a flag field with a code to set Yes to activities with total float bigger than one but less than 4. I have tried the IF then statement but cannot seem to get the range bit. I can do one or the other but not the between bit. Any help would be really appreciated.

    Andrew
    You don't need VB to do this. Open 'Customize Fields', select the flag field you want and click Formula.
    Enter
    IIf([Total Slack]>ProjDurConv("1 day",pjDays) And [Total Slack]<ProjDurConv("4 days",pjDays),Yes,No)
    Project stores duration fields in minutes, and since the number of working minutes in a day can be different in individual projects, it's best to use conversion functions where possible.

  5. #5
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •