How to assign macro to column

M

Marc De Smet

I want to create a column in MS Project 2003
called 'Number of resources' It should display the number
of resources allocated to the task.

In Visual Basic ActiveCell.Task.Assignments.Count returns
this number. But this is not accepted as a formula in
Customize Fields.

How can I assign this macro to this column (or is there a
different way of getting the number of allocated
resources in that column?)?

Thanks a lot for your help.

Kind regards

Marc
 
R

Rod Gill

Hi,

A formula won't do it, but a macro can. In Project:
Press Alt+F11
Insert Module
Copy and paste the following code:
Sub AssignmentsCount()
Dim T As Task
For Each T In ActiveProject.Tasks
If Not T Is Nothing Then
T.Number1 = T.Assignments.Count
End If
Next T
End Sub

Alt tab to the project
Run the macro by:
Tools, Macro, Macros (or Alt+F8)
select and run the AssignmentsCount macro. It will enter the number of
assignments into eh Number1 field

--
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/
 
J

John

Marc,
I don't think you can get there with a formula. However the following
simple macro will put the number of resources assigned to each task in
the Number1 field.

Sub NumAss()
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
t.Number1 = t.Assignments.Count
End If
Next t
End Sub

John
 

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