N
nickc
I am trying (and I mean trying) to create a subroutine for calculating an
"Adjusted Variance" field. I certainly have a ways to go with VBA, as I
thought I got everything be-bugged and working last night - only to be more
disappointed looking at the results in the immediate window. I am
responsible for monitoring various KPI's (key performance indicators) for our
service providers (SP's). One of these is % time to completion. The
challenge with the % time to completion thing is cases where the SP has a
dependency (from) which is out of their control. So if the dependency is
late, so is the service provider on their tasks. I need to account for this
and give them "credit" for the portion of + variance which was not their
responsibility. So I got this great idea (so I thought) to create an
"Adjusted Finish Variance" variable (array). I was trying to get the program
to cycle through each task, look up an identifier for the SP when it found
this, then look to see if the from dependency was that of another resource,
and if so subtract the finish variance of that resource from the SP's finish
variance. For example, if our SP has 4 days positive finish variance, and
the from dependency was not them, but another resource, and that resource was
late 2 days, then the adjusted finish variance for our SP would be 4 - 2 =
+2. One challenge I am having is understanding the relations between tasks,
resources, and assignments when it comes to VBA. I tried utilizing the
resource group field, however the program does not seem to be picking it up
from each task. In fact, it is ignoring the tasks with resource group "KPI".
I know there's probably an easier way than this VBA, however I would like to
learn it for other purposes such as entering time phased data via forms.
Here is my attempt at VBA, would appreciate any feedback.
Sub adjusted_variance()
Dim tsk As Task
Dim adj_var() As Integer
Dim z As Integer
Dim dep As TaskDependency
z = 0
For Each tsk In ActiveProject.Tasks
If tsk.ResourceGroup = "KPI" And tsk.Predecessors <> "NA" Then
For Each dep In tsk.TaskDependencies
MsgBox (tsk.Name) & (tsk.Predecessors)
If dep.From.ResourceGroup = support Then
z = z + 1
ReDim adj_var(z)
adj_var(z) = tsk.FinishVariance - dep.From.FinishVariance
Debug.Print adj_var(z)
Debug.Print (tsk.Name) & (tsk.Predecessors)
End If
Next dep
End If
Next tsk
End Sub
"Adjusted Variance" field. I certainly have a ways to go with VBA, as I
thought I got everything be-bugged and working last night - only to be more
disappointed looking at the results in the immediate window. I am
responsible for monitoring various KPI's (key performance indicators) for our
service providers (SP's). One of these is % time to completion. The
challenge with the % time to completion thing is cases where the SP has a
dependency (from) which is out of their control. So if the dependency is
late, so is the service provider on their tasks. I need to account for this
and give them "credit" for the portion of + variance which was not their
responsibility. So I got this great idea (so I thought) to create an
"Adjusted Finish Variance" variable (array). I was trying to get the program
to cycle through each task, look up an identifier for the SP when it found
this, then look to see if the from dependency was that of another resource,
and if so subtract the finish variance of that resource from the SP's finish
variance. For example, if our SP has 4 days positive finish variance, and
the from dependency was not them, but another resource, and that resource was
late 2 days, then the adjusted finish variance for our SP would be 4 - 2 =
+2. One challenge I am having is understanding the relations between tasks,
resources, and assignments when it comes to VBA. I tried utilizing the
resource group field, however the program does not seem to be picking it up
from each task. In fact, it is ignoring the tasks with resource group "KPI".
I know there's probably an easier way than this VBA, however I would like to
learn it for other purposes such as entering time phased data via forms.
Here is my attempt at VBA, would appreciate any feedback.
Sub adjusted_variance()
Dim tsk As Task
Dim adj_var() As Integer
Dim z As Integer
Dim dep As TaskDependency
z = 0
For Each tsk In ActiveProject.Tasks
If tsk.ResourceGroup = "KPI" And tsk.Predecessors <> "NA" Then
For Each dep In tsk.TaskDependencies
MsgBox (tsk.Name) & (tsk.Predecessors)
If dep.From.ResourceGroup = support Then
z = z + 1
ReDim adj_var(z)
adj_var(z) = tsk.FinishVariance - dep.From.FinishVariance
Debug.Print adj_var(z)
Debug.Print (tsk.Name) & (tsk.Predecessors)
End If
Next dep
End If
Next tsk
End Sub