Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Run time error 1004 Object defined error

Hi,

My code works when stepped through where the sheet CSV is opened but
does not work in a button when the sheet is not open. The goal of the
code is to format then create a copy of the sheet in a separate
workbook. Please advise of more efficient code than below:

Sub FormatCSV()
Dim r As Range
On Error Resume Next 'In case there are no blank rows
Worksheets("CSV").Columns("A").SpecialCells(xlCell TypeBlanks).EntireRow.Delete
On Error GoTo 0

Set r = Worksheets("CSV").Range("E1", Range("E10000").End(xlUp)) '
ERROR HERE
r.Value = "Default Project"
Worksheets("CSV").Columns("F:G").Select
Selection.Delete Shift:=xlToLeft
Worksheets("CSV").Rows("1:1").Select
Selection.Insert Shift:=xlDown

Application.Goto Reference:="header"
Selection.Copy
Sheets("CSV").Select
Range("A1").Select
ActiveSheet.Paste

Worksheets("CSV").Copy
ActiveSheet.Select

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Run time error 1004 Object defined error

The error occurs because Range("E10000") isn't qualified.
Try this:
Set r = Worksheets("CSV").Range("E1", _
Worksheets("CDV").Range("E10000").End(xlUp))

Efficiency? Get rid of the Selects as much as possible, e.g.:
Worksheets("CSV").Columns("F:G").Delete Shift:=xlToLeft

Hth,
Merjet



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 1004: Application-Defined or Object-Defined Error Diana[_7_] Excel Programming 6 April 17th 07 04:21 PM
Run Time Error 1004 - Application-defined or object-defined error brent Excel Programming 2 October 3rd 05 05:23 PM
Run-time Error 1004: Application-defined or Object-defined Error Adrian Excel Programming 6 August 23rd 05 06:28 AM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


All times are GMT +1. The time now is 11:33 AM.

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"