Macro, being taken to Macro text when execution

R

RudeRam

I am using the below code to color code the names if they appear in th
cells below the heaing Pilot, when I execute the macro I am taken t
the macro with the End Sub highlighted. Not sure what I am doing wron
here, any help is appericated.

Sub Colorcells()
For Line = 150 To 1 Step -1
If Pilot = "Lyon" Or Pilot = "Post" Or Pilot = "Hall" Or Pilot
"Cabot" Or Pilot = "Baganai" Or Pilot = "Cline" Or Pilot = "Goldfein
Or Pilot = "Fink" Then
Cells(Line, 7).Select
Selection.Font.ColorIndex = 5
End If
End Su
 
T

Trevor Shuttleworth

One way:

Sub ColorCells()
' name the column as "Pilot"
Dim Cell As Range
Application.ScreenUpdating = False
For Each Cell In Intersect(Range("Pilot"), ActiveSheet.UsedRange)
If Cell = "Lyon" Or _
Cell = "Post" Or _
Cell = "Hall" Or _
Cell = "Cabot" Or _
Cell = "Baganai" Or _
Cell = "Cline" Or _
Cell = "Goldfein" Or _
Cell = "Fink" Then
Cell.Font.ColorIndex = 5
End If
Next
Application.ScreenUpdating = True
End Sub

Regards

Trevor
 
Top