Changing Resource Units for Each Task

C

Cristina Pupper

Hello Everyone!

I want to create a VBA macro that changes the resource units for each task
in a project. Right now I have to manually go through each task in a project
and change the resource units by hand. I want to write a macro that would
look like the following:

For each Task in the Active Project
For each Resource Assigned to the Task
If Resource Name = "DAN"
Change Resource Units to 50%
Else
Change Resource Units to 25%
Endif
Next Resource
Next Task

I know enough VBA to write the loop that accesses each task in the Active
Project. What I do not understand is how to access the resources assigned to
each task. I was looking at the Assignments collection for each task, but
did not see a units property.

Thanks!

Cristina
 
R

Rod Gill

Hi,

Try something like:

sub test
Dim R as Resource
Dim A as assignment
for each r in activeproject.resources
if not r is nothing then 'make sure it's not a Null resource
If r.name="Dan" then
for each a in r.assignments
a.units=.5
next a
else

for each a in r.assignments
a.units=.25
next a
endif
endif
next r
end sub


Copy this code to a Module. Haven't tested it, but it'll be close.
--
For VBA posts, please use the public.project.developer group.
For any version of Project use public.project
For any version of Project Server use public. project.server

Rod Gill
Project MVP
For Microsoft Project companion projects, best practices and Project VBA
development services
visit www.projectlearning.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top