Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Application-defined or object-defined error

I get an error in this macro.

It is listed as

"Run-time error ('1004':

Application-defined or object-defined error"


The error is caused by this line:

.Range(Cells(4, 1), Cells(totalrows, 6)).Clear


Sub clearStreetSummary()
Dim totalrows As Integer

With Sheets("Street Summary")
totalrows = .UsedRange.Rows.count + 2
If totalrows 3 Then
.Range(Cells(4, 1), Cells(totalrows, 6)).Clear
End If
End With

End Sub



I was certain this macro ran at least once.

Can someone please help with this?

Ken Loomis


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Application-defined or object-defined error

Street Summary is probably not the active sheet when the macro runs. If that's
the case, you are trying to define a range on that sheet (Street Summary)
using references to cells on a different sheet, namely the ACTIVE sheet. Won't
work, of course.

I suspect you forgot the periods in front of the two Cells properties. Try it
like this and report back, please:

Sub clearStreetSummary()
Dim totalrows As Integer

With Sheets("Street Summary")
totalrows = .UsedRange.Rows.count + 2
If totalrows 3 Then
.Range(.Cells(4, 1), .Cells(totalrows, 6)).Clear
End If
End With
End Sub

On Tue, 12 Oct 2004 17:47:07 -0700, "Ken Loomis" wrote:

I get an error in this macro.

It is listed as

"Run-time error ('1004':

Application-defined or object-defined error"


The error is caused by this line:

.Range(Cells(4, 1), Cells(totalrows, 6)).Clear


Sub clearStreetSummary()
Dim totalrows As Integer

With Sheets("Street Summary")
totalrows = .UsedRange.Rows.count + 2
If totalrows 3 Then
.Range(Cells(4, 1), Cells(totalrows, 6)).Clear
End If
End With

End Sub



I was certain this macro ran at least once.

Can someone please help with this?

Ken Loomis


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Application-defined or object-defined error

Thanks, Myrna.

That was it.

Ken Loomis

"Myrna Larson" wrote in message
...
Street Summary is probably not the active sheet when the macro runs. If
that's
the case, you are trying to define a range on that sheet (Street Summary)
using references to cells on a different sheet, namely the ACTIVE sheet.
Won't
work, of course.

I suspect you forgot the periods in front of the two Cells properties. Try
it
like this and report back, please:

Sub clearStreetSummary()
Dim totalrows As Integer

With Sheets("Street Summary")
totalrows = .UsedRange.Rows.count + 2
If totalrows 3 Then
.Range(.Cells(4, 1), .Cells(totalrows, 6)).Clear
End If
End With
End Sub

On Tue, 12 Oct 2004 17:47:07 -0700, "Ken Loomis"
wrote:

I get an error in this macro.

It is listed as

"Run-time error ('1004':

Application-defined or object-defined error"


The error is caused by this line:

.Range(Cells(4, 1), Cells(totalrows, 6)).Clear


Sub clearStreetSummary()
Dim totalrows As Integer

With Sheets("Street Summary")
totalrows = .UsedRange.Rows.count + 2
If totalrows 3 Then
.Range(Cells(4, 1), Cells(totalrows, 6)).Clear
End If
End With

End Sub



I was certain this macro ran at least once.

Can someone please help with this?

Ken Loomis




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
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 tina salgia Excel Programming 0 August 24th 03 10:35 PM


All times are GMT +1. The time now is 05:28 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"