View Full Version : Solved: MSP 2003 - Set flag from summary to task
paddy69
10-26-2007, 02:18 AM
I have a flag for inactive tasks. Whenever I change this flag for the summary task, I want all tasks within that summary to be updated accordingly.
Before:
Summary Task1 = Yes
Task A = No
Task B = No
Task C = No
After:
Summary Task 1 = Yes
Task A = Yes
Task B = Yes
Task B = Yes
Thanks for your help.
mallarym
10-31-2007, 04:29 AM
x
mallarym
10-31-2007, 04:31 AM
dim tk as task
for each tk in activeproject.tasks
if tk.outlineparent.flag1="Yes" then
tk.flag1="Yes"
end if
next tk
paddy69
11-01-2007, 04:23 AM
It doesn't seem to work.
If have updated the VBA a little bit but now all tasks (summaries and non summaries) get updated.
For Each tk In ActiveProject.Tasks
If tk.OutlineParent.EnterpriseFlag4 = True Then
tk.EnterpriseFlag4 = "Yes"
End If
Next tk
Any suggestions?
mallarym
11-01-2007, 04:40 AM
ok, I need a little more information.
How many levels of tasks do you have?
When you say that all get updated, what do you mean exactly? (an common example like your first post would be helpful).
paddy69
11-01-2007, 05:51 AM
I have tasks with one summary level.
Belwo the result after running the VBA:
Before:
Summary Task1 = Yes
Task A = No
Task B = No
Task C = No
Summary Task2 = No
Task D = No
Task E = No
Task F = No
After:
Summary Task1 = Yes
Task A = Yes
Task B = Yes
Task C = Yes
Summary Task2 = Yes
Task D = Yes
Task E = Yes
Task F = Yes
I expected that only task under summary task 1 would be Yes. All tasks under summary 2 should remain No.
Thanks.
mallarym
11-01-2007, 06:20 AM
Add a separate procedure to find your levels:
Public Function NumberofDecimals(WBS As String) As Long
Dim instr1 As Long
Dim instr2 As Long
Dim Level As Long
instr1 = 1
Level = 1
Do
instr2 = InStr(instr1, WBS, ".")
If instr2 = 0 Then
Exit Do
Else
instr1 = instr2 + 1
Level = Level + 1
End If
Loop
NumberofDecimals = Level
End Function
Then modify your code for your flag's to:
Dim tk As Task
For Each tk In ActiveProject.Tasks
Level = NumberofDecimals(tk.WBS)
If Level > 1 And tk.OutlineParent.Flag1 = True Then
tk.Flag1 = True
End If
Next tk
paddy69
11-01-2007, 07:02 AM
Thanks, it works!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.