Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
Application-defined or object-defined error Please Help [email protected] Excel Discussion (Misc queries) 1 April 3rd 06 01:00 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM
VBA - Application-defined or object-defined error Chip Pearson Excel Programming 0 August 24th 03 08:43 PM


All times are GMT +1. The time now is 10:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"