The routine below loops through all rows in the Project and, based on the number in one custom field, changes the background color of that cell. Works fine, except:
The problem is that this routine loops through tasks and then uses "SelectTaskField Row:= taskID" to get to the field/cell that I want to modify. To make this work I have to do "OutlineShowAllTasks", so that the Row number will correlate with the Task ID. That changes the display of tasks that are closed.
(The routine toggles the "Change Highlighting" because otherwise that will override the highlighting that the routine makes).
Solutions might be:
1) address the field by task instead of row
2) recognize which tasks are closed, memorize those, then re-open them
3) something else?
Any suggestions on this would be appreciated
Sub SetPriorityColors() Dim wrkCHFlag As Boolean wrkCHFlag = False If EnableChangeHighlighting Then ToggleChangeHighlighting wrkCHFlag = True End If ScreenUpdating = False ScreenUpdating = True Set ts = ActiveProject.Tasks For n = 1 To ts.Count If Not ts(n) Is Nothing Then ts(n).OutlineShowAllTasks End If Next n
For n = 1 To ts.Count If Not ts(n) Is Nothing Then Set tsk = ts(n) SelectTaskField Row:=tsk.ID, Column:="Number10", RowRelative:=False Select Case tsk.Number10 Case Is >= 9 Font32Ex CellColor:=&HFF99CC Case Is >= 8 Font32Ex CellColor:=&H66CCFF Case Is >= 7 Font32Ex CellColor:=&H66FFFF Case Is = 0 Font32Ex CellColor:=&HFFFFFF Case Is = 3 Font32Ex CellColor:=&HFFCC99 End Select End If Next n If wrkCHFlag Then ToggleChangeHighlighting End If SelectTaskField Row:="1", Column:="Number10", RowRelative:=False End Sub