Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Error 1004 after copying 84th worksheet to a new workbook...

Hi,
I've got a workbook which has a template sheet (shtCopy) and macros in it.
The macro scans data from many files and creates a 1-pager summary on each
file using the template (shtCopy) .

It puts all the 1-pagers into a single new workbook (wbFinal)

Everything seems to work fine until it gets to file/sheet #84.

Then the macro crashes at the following point giving error 1004.
shtCopy.Copy after:=wbFinal.Sheets(1)

Excel says the number of worksheets and named ranges are only limited by
memory of which I have plenty. The filesize up to this point is only about
3MB so it's really not that big.

Any ideas why I could be getting this problem?
I routinely deal with excel files well over 30 Meg so this is very odd.


Thanks for any idea,
MikeZz

Here's the routine that actually causes the error:

Private Sub Create_Contract_Summary(f)
'shtCopy
Dim DefSheets

If workbookCreated = False And CreateNewWB = True Then
workbookCreated = True
Workbooks.Add
DefSheets = ActiveWorkbook.Sheets.Count
Set wbFinal = ActiveWorkbook

Application.DisplayAlerts = False
Do While ActiveWorkbook.Sheets.Count 1
ActiveSheet.Delete
Loop
Application.DisplayAlerts = True
Set shtSummary = ActiveSheet
shtSummary.Name = "Summary"
ElseIf f = 1 And CreateNewWB = False Then
Set wbFinal = ThisWorkbook
End If

shtCopy.Copy after:=wbFinal.Sheets(1)
Set shtPaste = ActiveSheet

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Error 1004 after copying 84th worksheet to a new workbook...

It's not really clear what all your variables mean in the code you posted.
Is there any additional code that gives the result of those variables? I
figured it would be a memory issue, because you say it runs smoothly for all
other worksheets added.


--
Cheers,
Ryan


"MikeZz" wrote:

Hi,
I've got a workbook which has a template sheet (shtCopy) and macros in it.
The macro scans data from many files and creates a 1-pager summary on each
file using the template (shtCopy) .

It puts all the 1-pagers into a single new workbook (wbFinal)

Everything seems to work fine until it gets to file/sheet #84.

Then the macro crashes at the following point giving error 1004.
shtCopy.Copy after:=wbFinal.Sheets(1)

Excel says the number of worksheets and named ranges are only limited by
memory of which I have plenty. The filesize up to this point is only about
3MB so it's really not that big.

Any ideas why I could be getting this problem?
I routinely deal with excel files well over 30 Meg so this is very odd.


Thanks for any idea,
MikeZz

Here's the routine that actually causes the error:

Private Sub Create_Contract_Summary(f)
'shtCopy
Dim DefSheets

If workbookCreated = False And CreateNewWB = True Then
workbookCreated = True
Workbooks.Add
DefSheets = ActiveWorkbook.Sheets.Count
Set wbFinal = ActiveWorkbook

Application.DisplayAlerts = False
Do While ActiveWorkbook.Sheets.Count 1
ActiveSheet.Delete
Loop
Application.DisplayAlerts = True
Set shtSummary = ActiveSheet
shtSummary.Name = "Summary"
ElseIf f = 1 And CreateNewWB = False Then
Set wbFinal = ThisWorkbook
End If

shtCopy.Copy after:=wbFinal.Sheets(1)
Set shtPaste = ActiveSheet

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
Cannot close a workbook in VBA due to Run-Time error '1004' Tom Med Excel Programming 3 September 24th 07 04:10 PM
Copy paste to another Workbook, Error 1004 Steve[_87_] Excel Programming 7 April 16th 07 05:49 PM
Opening a workbook, passwords and error 1004. droopy928gt[_10_] Excel Programming 2 April 27th 06 01:23 PM
workbook.open throws 1004 error [email protected] Excel Programming 3 April 3rd 06 11:37 PM
shared workbook runtime error 1004 Nigel[_10_] Excel Programming 10 August 2nd 05 07:09 PM


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