Run-time error '91'?

S

SonT

Please tell me why I get "Run-time error '91'

Sub Macro10()

Dim b As Integer
b = ActiveProject.Tasks.Count
For b = b To 1 Step -1
SelectCell Row:=b, Column:=5, RowRelative:=False
If ActiveCell.Task.Type = 1 Then ActiveCell.CellColor = pjRed
If ActiveCell.Task.Type = 2 Then ActiveCell.CellColor = pjColorAutomatic
If ActiveCell.Task.Type = 3 Then ActiveCell.CellColor = pjColorAutomatic
If ActiveCell.Task.Type = 0 Then ActiveCell.CellColor = pjColorAutomatic
Next b

End Sub

Thank you.
 
S

SonT

Below are my new codes, but I still get the same errors:
Sub Macro10()

Dim b As Integer

b = ActiveProject.Tasks.Count

For b = b To 1 Step -1
SelectCell Row:=b, Column:=5, RowRelative:=False

If ActiveCell.Task.Type = pjFixedDuration Then ActiveCell.CellColor = pjRed
If ActiveCell.Task.Type = pjFixedUnits Then ActiveCell.CellColor =
pjColorAutomatic
If ActiveCell.Task.Type = pjFixedWork Then ActiveCell.CellColor =
pjColorAutomatic

Next b
End Sub
 
Top