What Im after is an additional bar type alongside the two bars in a critical path view ie, critical = red 0TF blue for activities with Tf bigger than 4days and a near critical activity with TF less than 4. I have added this bar as a flag and what I would like to be able to do is have the chart update automatically to show these bars.
Andrew
Member for
20 years 7 months
Member for20 years8 months
Submitted by Niek Zonneveld on Tue, 2011-09-13 19:00
I am using the field flag20 as my yes/no - I have set a bar in the view to be green if flag 20 is yes. I first clear the flag20 field - that works. I then run a filter - that works. But wehn I run the next bit where I want the filtered bars flag20 filed to be yes it only makes the first bar yes and does not change any more. Any ideas.
Regards
Andrew
Sub Colourfiltergreen()
' Macro Colourfiltergreen
' Macro Recorded 13/09/11 by Andrew Owenson.
Dim jTasks As Tasks
Dim jTask As Task
'clear the flag field
For Each jTask In ActiveProject.Tasks
If Not jTask Is Nothing Then
jTask.Flag20 = "No"
End If
Next jTask
'set the flag field for the selected task
FilterApply Name:="Near Critical"
For Each jTask In ActiveSelection.Tasks
If Not jTask Is Nothing Then
jTask.Flag20 = "Yes"
End If
Next jTask
FilterApply Name:="All Tasks"
End Sub
Member for
20 years 7 months
Member for20 years8 months
Submitted by Niek Zonneveld on Mon, 2011-09-12 12:40
Member for
17 years 4 monthsNiek Many thanks for your
Niek
Many thanks for your help, it has set me on the correct path.
Andrew
Member for
17 years 4 monthsDarren What Im after is an
Darren
What Im after is an additional bar type alongside the two bars in a critical path view ie, critical = red 0TF blue for activities with Tf bigger than 4days and a near critical activity with TF less than 4. I have added this bar as a flag and what I would like to be able to do is have the chart update automatically to show these bars.
Andrew
Member for
20 years 7 monthsAndrew,I guess it won't
Andrew,
I guess it won't automatically select the tasks you've filtered (see line in bold), so you loop through 1 active line only.
It's probably safer is to use the filter criteria (hard coded) in the loop itself. (less flexible, probably but...)
H.T.H.
Niek.
*****************
'set the flag field for the selected task
FilterApply Name:="Near Critical"
For Each jTask In ActiveSelection.Tasks
If Not jTask Is Nothing Then
jTask.Flag20 = "Yes"
End If
Next jTask
Member for
17 years 9 monthsHi Andrew, If you're already
Hi Andrew,
If you're already using Filters for your macro, have you thought about just formatting a new Task Bar using Bar Styles?
Saves things getting overly complicated by going down the VBA route.
Regards,
Darren Kosa
Member for
17 years 4 monthsNiek Thankyou for your
Niek
Thankyou for your interest.
This is what I have done.
I am using the field flag20 as my yes/no - I have set a bar in the view to be green if flag 20 is yes. I first clear the flag20 field - that works. I then run a filter - that works. But wehn I run the next bit where I want the filtered bars flag20 filed to be yes it only makes the first bar yes and does not change any more. Any ideas.
Regards
Andrew
Sub Colourfiltergreen()
' Macro Colourfiltergreen
' Macro Recorded 13/09/11 by Andrew Owenson.
Dim jTasks As Tasks
Dim jTask As Task
'clear the flag field
For Each jTask In ActiveProject.Tasks
If Not jTask Is Nothing Then
jTask.Flag20 = "No"
End If
Next jTask
'set the flag field for the selected task
FilterApply Name:="Near Critical"
For Each jTask In ActiveSelection.Tasks
If Not jTask Is Nothing Then
jTask.Flag20 = "Yes"
End If
Next jTask
FilterApply Name:="All Tasks"
End Sub
Member for
20 years 7 monthsAndrew,I would go with a
Andrew,
I would go with a structure like below.
For all tasks that meet your filter criteria you have the field "Marked" set to "Yes" by the macro.
The next step is to create a view where the bar for a 'marked' task is shown in a different color.
HTH
Niek.
--------------------
Sub Color_line()
Dim t As Task
Dim Blank_Line As Integer
'This macro loops through all selected lines and changes the color based on the line meeting certain filter criteria.
For Each t In ActiveSelection.Tasks
If t Is Nothing Then
Blank_Line = Blank_Line + 1
ElseIf filter criteria Then
Tsk.Marked = "Yes"
Else
End If
Next t
End Sub