Macros for Alternative Resource Cost Rates

Here are some macros for working with alternative resource cost rates.

When editing a Resource’s Standard Rate this automatically sets Costs Rate A, visible in Resource Information.

resource name and rate

resource information costs

To set an alternative rate (B-E) you edit Resource Information, click the Costs tab and select an alternative Resource Cost Rate. This is tedious for a large resource pool.

Here’s a helpful macro to copy a Custom Resource Field into Rate Table B for all Resources.

First, create an Enterprise Resource Custom cost field named Std. Rate B.

rate

Second, open the Enterprise Resource Pool in Project Professional and add the new Std. Rate B column, populate for all resources.

resource name and rate

Third, run this macro to copy the Std. Rate B field value to the Standard Rate B Table for all resources.

Sub SetRateBfromEntField()

    'Declare Variables
    Dim Res As Resource

    'Loop All Resources
    For Each Res In ActiveProject.Resources
    
        'Check for Real Resource
        If Not (Res Is Nothing) Then
               
            'Set Rate Table B from Std. Rate B
            Res.CostRateTables(2).PayRates(Res.CostRateTables(2).PayRates.Count).StandardRate = Res.GetField(FieldNameToFieldConstant("Std. Rate B", pjResource))
            
        End If
           
    Next Res
    
End Sub

After running the macro all resources will have the Std. Rate B value for their Rate B Table.

resource information

Need to change the the Cost Rate used in a project?  Here are two additional macros for setting the Cost Rate on all project assignments.

Sub SetAllAssignmentsToCostRateB()

    'Declare Variables
    Dim Task As Task
    Dim Assignment As Assignment

    'Loop All Tasks
    For Each Task In ActiveProject.Tasks
    
        'Check for Real Task
        If Not (Task Is Nothing) Then
        
            'Loop All Assignments for the Task
            For Each Assignment In Task.Assignments
            
                'Check for Real Assignment
                If Not (Assignment Is Nothing) Then
                
                    'Change Cost Rate Table
                    Assignment.CostRateTable = 1
                    
                End If
            Next Assignment
        End If
    Next Task

End Sub

Sub SetAllAssignmentsToCostRateA()

    'Declare Variables
    Dim Task As Task
    Dim Assignment As Assignment

    'Loop All Tasks
    For Each Task In ActiveProject.Tasks
    
        'Check for Real Task
        If Not (Task Is Nothing) Then
        
            'Loop All Assignments for the Task
            For Each Assignment In Task.Assignments
            
                'Check for Real Assignment
                If Not (Assignment Is Nothing) Then
                
                    'Change Cost Rate Table
                    Assignment.CostRateTable = 0
                    
                End If
            Next Assignment
        End If
    Next Task

End Sub