Application defined or Object defined error

  • Thread starter FJ Shepley & JM Pfohl
  • Start date
F

FJ Shepley & JM Pfohl

I have two identical macros below except for the third line defining the
range is different. The first one doesn't work.
I keep getting an "Application defined or Object defined error". The
second works fine Can someone help?

First one doesn't work...

Private Sub Worksheet_Activate()
Dim ship As Range
For Each ship In Worksheets("newshipped").Range("c1",
Range("c1").End(xlRight))
If ship = "1" Then 'yesterday
ship.EntireColumn.Font.ColorIndex = 3
ship.EntireColumn.Font.Bold = False
ElseIf ship = "0" Then 'today
ship.EntireColumn.Font.ColorIndex = 1
ship.EntireColumn.Font.Bold = True
Else: ship.EntireColumn.Font.ColorIndex = 10
ship.EntireColumn.Font.Bold = False 'tomorrow
End If
Next ship
End Sub



SECOND this one works.


Private Sub Worksheet_Activate()
Dim ship As Range
For Each ship In Worksheets("shipped").Range("ak3",
Range("ak3").End(xlDown))
If ship = "1" Then 'yesterday
ship.EntireRow.Font.ColorIndex = 3
ship.EntireRow.Font.Bold = False
ElseIf ship = "0" Then 'today
ship.EntireRow.Font.ColorIndex = 1
ship.EntireRow.Font.Bold = True
Else: ship.EntireRow.Font.ColorIndex = 10
ship.EntireRow.Font.Bold = False 'tomorrow
End If
Next ship
End Sub
 

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

Top