NOTE: SPI is the ratio of work performed to work scheduled (BCWP/BCWS). CPI is the ratio of budgeted costs to actual costs (BCWP/ACWP).
The following macro calculates the Schedule Performance Index (SPI) and the Cost Performance Index (CPI) for each task and places the results into Numeric fields. The SPI for each task is equal to BCWP/BCWS. The CPI for each task is equal to BCWP/ACWP.
To create this macro, follow these steps:
- On the Tools menu, point to Macro, and then click Macros. For Project 2010, go to the View tab and click the Macros button.
- In the Macro name box, type CalcSPI_CPI, and then click Create to open the Visual Basic Editor.
- Create the macro by typing the following subroutine.
Dim t As Task
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.BCWS <> 0 Then
t.Number10 = t.BCWP / t.BCWS 'this calculates SPI
If t.ACWP <> 0 Then
t.Number11 = t.BCWP / t.ACWP 'this calculates CPI
NOTE: This example uses the Number10 and Number11 fields. You can use any of the other numeric and alphanumeric fields available. You may also want to use the Format function to format your results.
- In the Visual Basic Editor, on the File menu, click Close And Return To Microsoft Project.
- In Microsoft Project, on the Tools menu, point to Macro, and then click Macros. For Project 2010, go to the View tab and click the Macros button.
- In the list of macros, click CalcSPI_CPI. Click Run.
- On the Insert menu, click Column. For Project 2010, go to the Format tab and click the Insert Column button.
- In the Field name list, click Number10.
- Click OK.
- Repeat steps 1-3 for the Number11 field.
ID do Artigo: 209115 - Última Revisão: 26 de mar de 2013 - Revisão: 1