LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run-Time Error 1004

Alex,

I too experience the same thing... I'm copying a template, multiple times,
and populating it...

I've found, that if I copy 55 additional sheets (on top of 4 existing), I
get the error, any less, and I'm okay.

I have tried changing the name of the sheet, position, etc. but all to no
avail.

I haven't tested it, but another user suggested that a save, mid-process,
may help.

Good luck, I look forward to any solutions posted.

Cheers,

"Alex" wrote:

Hi,

Can anyone please workout why I'm getting a Run-Time Error 1004 (Copy method of worksheet class failed) in code after 30 sheets have been copied? Code works fine up until then. Is there a limit on how many sheets can be copied to new workbook. This is confusing because if your open a new file, it can have up to 255 sheets. All my code is doing is running through a list of names and for each copying a template sheet into a new workbook. I have 50 names which I need to create the same template sheet for each name and store in one new workbook. For some reason can't get past 30 sheets.

Appreciate any help with this.
Alex

XL2003 VBA


' loop
While (Ctr) < EmpCtr
CrtEmpName = Workbooks(DataFile).Sheets(DataSht).Cells(rCtr, 1).Value ' Master file containing employee names sheet

' copy template to new workbook on first occurance
If ShtCtr = 0 Then
Sheets(CalcSht).Copy ' Template sheet to copy
ActiveWorkbook.Sheets(CalcSht).Activate ' New workbook created with tempate sheet copied
CalcFile = ActiveWorkbook.Name '
Else
R-T Error -- Sheets(CalcSht).Copy After:=Workbooks(CalcFile).Sheets(ShtCtr)

End If
ActiveSheet.Name = CrtEmpName

Workbooks(DataFile).Sheets(CalcSht).Activate ' Master file containing template sheet
rCtr = rCtr + 1
Ctr = Ctr + 1
ShtCtr = ShtCtr + 1
Wend



 
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 shternm Excel Discussion (Misc queries) 7 October 3rd 05 07:38 PM
Run Time Error '1004' D Huber Excel Worksheet Functions 1 September 23rd 05 03:52 PM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Run-Time error '1004' Bob[_33_] Excel Programming 2 August 28th 03 03:10 PM


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

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"