ID: Q137673
The information in this article applies to:
The Microsoft Project Visual Basic for applications DateDifference, DateAdd, and DateSubract methods provide ways for you to create custom date calculations that take into consideration your project calendars.
The following macro uses the DateDifference method to calculate a task's planned percent complete based on working time. A task's planned percent complete can be used for custom earned value calculations.
Microsoft provides examples of Visual Basic for applications procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.
Sub Planned_Percent_Complete()
'Get the current date.
dCurrentDate = ActiveProject.CurrentDate
'Loop through each task in the project
For Each ATask In ActiveProject.Tasks
PlPctComp = 0
'skip blank rows
If Not ATask Is Nothing Then
'Check for Baseline Start and Baseline Finish
If (IsDate(ATask.BaselineStart) And _
IsDate(ATask.BaselineFinish)) Then
'Zero duration tasks
If dCurrentDate >= ATask.BaselineFinish Then
PlPctComp = "100%"
Else
vTemp = Application.DateDifference(ATask.BaselineStart, _
ATask.BaselineFinish)
If vTemp = 0 Then
PlPctComp = "0%"
Else
PlPctComp =
Format(Application.DateDifference(ATask.BaselineStart, _
dCurrentDate) / vTemp, "0%")
End If
End If
ATask.Text1 = PlPctComp
Else
'No baseline start/finish, set to NA
ATask.Text1 = "NA"
End If
End If
Next ATask
End Sub
Additional query words: 4.00 4.10 attached function BCWS
Keywords : kbcode kbprg
Version : 4.0 4.1 4.1a 98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto
Last Reviewed: November 25, 1997