Copy UserDefined Fields from Summary to subtask

H

Hadi

hello,

I have a master project with about 300 project in it. each one of these
project have about 40 subtasks underneath it. at the project name level
(lets say outline leve1) i have many user defined fields such as (PM,
Engineer, Budget, Location, etc). I want to be able to copy these values in
these fields dwon to the 40 tasks without having to use the fill down
feature. is there a smart macro out there.

BTW, 40 is just a number i picked, many of these projects will a different
number of subtasks

help is always appreciated
 
J

John

Hadi said:
hello,

I have a master project with about 300 project in it. each one of these
project have about 40 subtasks underneath it. at the project name level
(lets say outline leve1) i have many user defined fields such as (PM,
Engineer, Budget, Location, etc). I want to be able to copy these values in
these fields dwon to the 40 tasks without having to use the fill down
feature. is there a smart macro out there.

BTW, 40 is just a number i picked, many of these projects will a different
number of subtasks

help is always appreciated

Hadi,
I doubt you will find a ready made macro to do what you want, but
writing the code is not that difficult. And you are right, using
fill-down for 300 subprojects would be rather tedious.

The exact VBA code necessary is dependent on how the master is
structured. If all 300 subprojects are inserted at the same level (i.e.
none of the subprojects are inserted in other subprojects) and if the
data for user defined fields exists for task ID #1 at the subproject
level, then the following code will get you started.

Sub fill_down()
For Each sp In ActiveProject.Subprojects
seedvalue = sp.SourceProject.Tasks(1).Text10
For Each t In sp.SourceProject.Tasks
t.Text10 = seedvalue
Next t
Next sp
End Sub

Hope this helps.
John
Project MVP
 
H

Hadi

John, no i dont have subproject inside subprojects. all of them are
structured the same way. the only difference is the number of subtasks under
each project.

so i will get started with the macro you have. is that only for one text
field (text10). so i just need to change the number for each field i have?

also, can i use the code for enterprise text fields?

thanks
 
H

Hadi

John,
can I send you a small file to a couple of projects so you can see how my
master would be structured?

that would be a life saver
 
J

John

Hadi said:
John,
can I send you a small file to a couple of projects so you can see how my
master would be structured?

that would be a life saver

Hadi,
I thought life savers were those little round candy things - the ones
with the hole in the middle...

To answer your other questions, you didn't say which fields you are
using so I just picked Text10 as an example. You would need to capture
each field at the summary task level and then write the data into the
same field for the subtasks (i.e. seedvalue1, seedvalue2, etc. and
expand the inner loop to write each value). Enterprise text fields are
just another field when working in a Server environment.

John
Project MVP
 
H

Hadi

John,
what would the code look like if i want to perform the same action for task
and subtask instead of project subproject. lets say i have multiple sets of
tasks and subtasks in the same project file

thanks
 
J

John

Hadi said:
John,
what would the code look like if i want to perform the same action for task
and subtask instead of project subproject. lets say i have multiple sets of
tasks and subtasks in the same project file

thanks

Hadi,
Now you are asking a different question. What do you mean by the term
"task"? Do you really mean the summary task (which really isn't a task
at all)? Also, are summary lines nested?

If summary lines are NOT nested (i.e all at the same outline level in
any given project), the following code should get you started.

Sub fill_down_A()
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.Summary = True Then
Val1 = t.Text1
Val2 = t.Text2
For Each sp In t.OutlineChildren
sp.Text1 = Val1
sp.Text2 = Val2
Next sp
End If
End If
Next t
End Sub

John
Project MVP
 
H

Hadi

You are right, i meant summary task and sub task.

Here is what i have in any given file

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

i hope i explained myself a little better this time
 
J

John

Hadi said:
You are right, i meant summary task and sub task.

Here is what i have in any given file

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

i hope i explained myself a little better this time

Hadi,
So you DO have a nested structure. Ok, now what is it you want to do
again? If you are trying to copy spare fields from the parent task to
its children, then whatever spare fields appear for the summary task at
outline level 2 (for its children) may be overwritten when the spare
fields for the summary task at outline level 1 are copied.

John
Project MVP
 
H

Hadi

the text fields data is at the outline level1 and i want to copy it down to
the outlineleve2 and 3. the structure i layed out in the last reply
represents one of my projects where outlineleve1 would the project name,
outline level2 would have the main nine phases the project goes thru, and
outline level3 are the tasks. so in any given file i have multiple projects
that are structured the same.
 
J

John

Hadi said:
the text fields data is at the outline level1 and i want to copy it down to
the outlineleve2 and 3. the structure i layed out in the last reply
represents one of my projects where outlineleve1 would the project name,
outline level2 would have the main nine phases the project goes thru, and
outline level3 are the tasks. so in any given file i have multiple projects
that are structured the same.

Hadi,
Since your Outline Level 1 is the project name I will assume there is
only one task at that outline level. Given that, the following code
should get you there.

Sub fill_down_B()
Set base = ActiveProject.Tasks(1)
val1 = base.Text1
val2 = base.Text2
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.OutlineLevel > 1 Then
t.Text1 = val1
t.Text2 = val2
End If
End If
Next t
End Sub

John
Project MVP
 
H

Hadi

John,
I am really sorry if am not explaining myself very well. i tried the last
code i got from you and it seems to work. however, what i tried to say the
last post is I have more than one project in the same file. So the structure
i explained before might repeat more than once in any given file. so i have
multiple tasks at oultine level1

here is an example to represent one .mpp file

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

and so on

so the code i am looking for needs to copy the text fields down from one
summary task to its own nested summary tasks and subtasks.

thanks alot
 
J

John

Hadi said:
John,
I am really sorry if am not explaining myself very well. i tried the last
code i got from you and it seems to work. however, what i tried to say the
last post is I have more than one project in the same file. So the structure
i explained before might repeat more than once in any given file. so i have
multiple tasks at oultine level1

here is an example to represent one .mpp file

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

Summary task (outline level1)
9(ea) Summary tasks underneath (outline level2)
3 or 4 subtasks under the 9 (outline level3)

and so on

so the code i am looking for needs to copy the text fields down from one
summary task to its own nested summary tasks and subtasks.

thanks alot

Hadi,
See how much better the answers get when the statement of the problem is
more complete? It has taken a while but I think maybe we are now on the
same page. I'm going to do you one better and assume the summary tasks
at outline level 1 are actually the insertion point summary lines of
subprojects in a master file. This is based on what you indicated in
your first post. The code below should do it:

Sub fill_down_C()
OutlineShowTasks expandinsertedprojects:=True
SelectTaskColumn
Set Area = ActiveSelection.Tasks
For Each t In Area
If Not t Is Nothing Then
If t.OutlineLevel = 1 Then
val1 = t.Text1
val2 = t.Text2
Else
t.Text1 = val1
t.Text2 = val2
End If
End If
Next t

John
 
H

Hadi

John,
this is sweat. am going to be so much more effective now. this code seems
to be working smoothly.

thanks alot for your patience
 
J

John

Hadi said:
John,
this is sweat. am going to be so much more effective now. this code seems
to be working smoothly.

thanks alot for your patience

Hadi,
Uuuuh, I think you meant, "this is sweet". You're welcome.

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