Quick note to save someone down the road some time and frustration. :-)
When working with VBA TimeScaleValue collections in Microsoft Project 2007 or Microsoft Project 2010 remember that timescaled values that fall on nonworking days are not zeros. They are also not NULLs. They are in that shadow world between numbers and NULLs. They are “”. Why is this important you ask?
It is NOT important if you are just going to set the Value directly as in:
TSV(Counter).Value = $400.00
It is VERY important if you are doing a running total of creating a rollup inside of a loop (in my case a For…Next looping through sets of Tasks, as in:
TSV(Counter).Value = TSV(Counter).Value + TaskObject.Cost10
If you fire that second line of code off and the TSV(Counter).StartDate is a nonworking day AND there is not already a number in that value then the value that is there by default is that crazy shadow “” value. The result is a Type Mismatch error because you are trying to add your TaskObject.Cost10 to a non number.
So to get around this you have to test the current value of TSV(Counter).Value to see if it is numeric:
If IsNumeric(TSV(Counter).Value) = True then
TSV(Counter).Value = TSV(Counter).Value + TaskObject.Cost10
Else
TSV(Counter.Value = TaskObject.Cost10
End If
Now the first pass through this TSV ‘slice’ will show a nonnumeric value and it will just set the value to be the Cost10 value for the TaskObject. But on the second pass through this slice it will be a numeric value since you just set it on the first pass and then it can start your ‘rollup’.