View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Application defined or Object defined error

Hi FJ & JM,

Try changing:

xlRight

to:

:xlToRight

---
Regards,
Norman



"FJ Shepley & JM Pfohl" wrote in message
...
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