PDA

View Full Version : Need code help for highlighting rows with If statement



momcaro
11-20-2014, 07:19 AM
Hello,
I have the following code (which works) for coloring rows when tasks complete % is below the expected % complete (which is a custom field):

Sub SelectTaskRows()
Dim tskT As Task
For Each tskT In ActiveProject.Tasks
Select Case tskT.Number7
Case Is <= 0
SelectRow row:=tskT.ID, RowRelative:=False
Font32Ex CellColor:=&H9DF2BA
Case 0.1 To 30
SelectRow row:=tskT.ID, RowRelative:=False
Font32Ex CellColor:=&H46F5FF
Case 30.1 To 100
SelectRow row:=tskT.ID, RowRelative:=False
Font32Ex CellColor:=&H3760FE
End Select
Next tskT
End Sub

I would like to insert an If statement, to only color the rows green/yellow/red if the task is a milestone.
Being the VBA infant that I am, I cannot get it to work (I'm apparently missing pieces).

Could someone please help?
Thank you!
Caroline

BrynjulfRasm
09-16-2015, 05:36 AM
You solved your problem? if Yes then how?

momcaro
09-16-2015, 05:59 AM
You solved your problem? if Yes then how?

Yes. Here is what I have:

Sub SelectTaskRows()
Dim tskT As Task
For Each tskT In ActiveProject.Tasks
If tskT.Milestone = True Then
Select Case tskT.Number7
Case 0 To 10
SelectRow row:=tskT.ID, RowRelative:=False
Font32Ex CellColor:=&H9DF2BA
Case 10.1 To 40
SelectRow row:=tskT.ID, RowRelative:=False
Font32Ex CellColor:=&H46F5FF
Case 40.1 To 100
SelectRow row:=tskT.ID, RowRelative:=False
Font32Ex CellColor:=&H3760FE
End Select
End If
Next tskT
End Sub