Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Application defined or Object defined error
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Application defined or Object defined error
Thanks I will try tomorrow at work.
"Norman Jones" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-time error '50290': Application-defined or object-defined erro | Excel Discussion (Misc queries) | |||
Application-defined or object-defined error Please Help | Excel Discussion (Misc queries) | |||
Macro Run-time Error 1004 Application Defined or Object Defined Error | Excel Programming | |||
Runtime Error 1004 -- Application Defined or Object Defined Error | Excel Programming | |||
VBA - Application-defined or object-defined error | Excel Programming |