Macro, being taken to Macro text when execution

  • Thread starter Thread starter RudeRam
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top