Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
~L ~L is offline
external usenet poster
 
Posts: 177
Default Runtime 1004 Error Help Request

The code
If Worksheets("cover sheet").Range("H7") < "" And Worksheets("cover
sheet").Range("O10") < "" And Worksheets("cover sheet").Range("E11") < ""
Then
If Len(Dir(mypath & myname & ".xls")) = 0 Then
Application.DisplayAlerts = False
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=mypath & myname & ".xls"
Windows("Script with Macros.xls").Activate
Cells.Select
Selection.Copy
Windows(myname & ".xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets.Add After:=Sheets(Sheets.Count)
Windows("Script with Macros.xls").Activate
Sheets("DIST " & mq).Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows(myname & ".xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Dist 17, 67, 196"
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Cover Sheet"
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Sheets("Cover Sheet").Select
Application.DisplayAlerts = True
End If
End If

Halts just after executing:

Sheets("DIST " & mq).Select

and produces the runtime 1004 error.

I'm having difficulty understanding why.

Any thoughts?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Runtime 1004 Error Help Request

1004 is subscript out of range and generally it means that you are trying to
access something that does not exist. For example you can not select Cell A0
since the first row of a spreadsheet is row 1. In your case you are trying to
select a sheet that does not exist in the currently active workbook. In the
code take note of which workbook is active when the code executes and ensure
that the name of the worksheet is exactly the same as the name you are
referencing. Spelling and blank spaces count so double check what you have...
--
HTH...

Jim Thomlinson


"~L" wrote:

The code
If Worksheets("cover sheet").Range("H7") < "" And Worksheets("cover
sheet").Range("O10") < "" And Worksheets("cover sheet").Range("E11") < ""
Then
If Len(Dir(mypath & myname & ".xls")) = 0 Then
Application.DisplayAlerts = False
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=mypath & myname & ".xls"
Windows("Script with Macros.xls").Activate
Cells.Select
Selection.Copy
Windows(myname & ".xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets.Add After:=Sheets(Sheets.Count)
Windows("Script with Macros.xls").Activate
Sheets("DIST " & mq).Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Windows(myname & ".xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Dist 17, 67, 196"
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Cover Sheet"
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Sheets("Cover Sheet").Select
Application.DisplayAlerts = True
End If
End If

Halts just after executing:

Sheets("DIST " & mq).Select

and produces the runtime 1004 error.

I'm having difficulty understanding why.

Any thoughts?

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
runtime error '1004' application or object defined error Janis Excel Programming 4 November 18th 09 03:01 PM
Run-time error '1004' . Please help. Request for immediate attent BEETAL Excel Programming 1 September 10th 08 09:09 AM
getting Runtime Error 1004 ArielZusya Excel Programming 8 January 17th 08 06:28 PM
runtime error '1004' application or object defined error. Please help deej Excel Programming 0 August 1st 07 09:26 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM


All times are GMT +1. The time now is 07:42 AM.

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

About Us

"It's about Microsoft Excel"