Stated Problem,
If more than one task is selected and the following code
is run, If there is a task that is not yet scheduled to
start that task's Finish 1 field will not be calculated.
Tips: Baseline a couple of Tasks front loaded. Make some
tasks set to start some time in the future. Also I set my
barestyles to shade progress against the baseline from
Baseline Start to Finish1.
Here is the code. I left the comments in so that you can
better understand why I was trying to write this code. If
you see errors in the code outside of my stated problem,
then please give suggestins on that as well. Thank You
'This Macro was created by Dan XXX of XXX
'Created on 6/5/03.
'This macro was created in an attempt to status
against Baseline work instead of
'Baseline Duration. Statusing against Baseline
Duration is fine IF you do not
'have any type of work curve.
'The Problem
'Assume the task below is 5 days long, has a BAC of
40hrs, and is 60% Complete.
'Day1 Day2 Day3 Day4 Day5
'12 12 8 4 4
'DateDiff ****************
'TimePhased ----------
'Using a DateDiff Formula *****
'5 Days * 60% = 3 Days
'Using TimePhased Formula ------
'BCWP = 24 hrs
'Day 1 = 12 Sum = 12
'Day 2 = 12 Sum = 24
'*This is actually done like this on a hours basis
'This macro works by incrementally adding up baseline
work by the hour for a task.
'As soon as the Summed up work meets or exceeds the
calculated work percent complete
'it stops and returns that hours end time.
Sub BLWorkPerDay()
Dim TSV As TimeScaleValues, HowMany As Long
Dim T As Task
Dim SumValue As Long
Dim HoursPerDay As String
Dim CalcBCWP As Double
Dim CalcEndDate As Date
If Not (ActiveSelection.Tasks Is Nothing) Then
For Each T In ActiveSelection.Tasks
Set TSV = ActiveCell.Task.TimeScaleData
(T.BaselineStart, T.BaselineFinish,
pjTaskTimescaledBaselineWork, pjTimescaleHours, 1)
SumValue = 0
CalcBCWP = (T.PercentWorkComplete / 100) *
T.BaselineWork
For HowMany = 1 To TSV.Count
If Not TSV(HowMany).Value = "" Then
If TSV(HowMany).Value + SumValue < CalcBCWP
Then
SumValue = SumValue + TSV(HowMany).Value
Else
CalcEndDate = TSV(HowMany).EndDate
T.Finish1 = CalcEndDate
GoTo DansEnd
End If
End If
Next HowMany
DansEnd:
Next T
End If
End Sub
Quote:
>-----Original Message-----
>DMS,
>It might be easier to help find the problem if we could
see your code.
>If it isn't too lengthy (less than 50 lines), just post
it here. If it
>is long and involved send it to me via e-mail along with
the zipped
>project file and I'll have a look at it.
>John
>.