Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default Peculiar Problem when Doing a Sheet.Copy

Excel 2003. I have some code that copies sheet by sheet from one workbook
into another, renaming the sheets as it goes. Even though the source
workbook has 80 sheets, the copy never gets past the 58th sheet, then errors
out. I have tried using various source workbooks and always bomb at the 58th
sheet. It is not a problem with the sheet being copied. Here is the code:

For Each sh In TempWb.Sheets
'Copy
sh.Copy After:=Workbooks(YTDWbName).Sheets(1)
'Rename
YTDWb.ActiveSheet.Name = Mid(YTDWb.ActiveSheet.Name, 1, 27) + "(4)"
Next sh

What could be my problem? Thanks and God bless for any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Peculiar Problem when Doing a Sheet.Copy

POSSIBLY it's a memory issue, but IF all sheets are being copied and
renamed, why not change tack and save the workbook AS a different name
(thus creating another copy) and rename each sheet in this one?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Peculiar Problem when Doing a Sheet.Copy

Excel seems to have a problem with repetitive copying of sheets.

cnt = TempWb.sheets.count
TempWb.Sheets.copy After:=Workbooks(YTDWbName).Sheets(1)
for i = 2 to cnt + 1
With Workbooks(YTDWbName).sheets(i)
.Name = Mid(.Name, 1, 27) & "(4)"
Next sh
Next

--
Regards,
Tom Ogilvy


"Chaplain Doug" wrote:

Excel 2003. I have some code that copies sheet by sheet from one workbook
into another, renaming the sheets as it goes. Even though the source
workbook has 80 sheets, the copy never gets past the 58th sheet, then errors
out. I have tried using various source workbooks and always bomb at the 58th
sheet. It is not a problem with the sheet being copied. Here is the code:

For Each sh In TempWb.Sheets
'Copy
sh.Copy After:=Workbooks(YTDWbName).Sheets(1)
'Rename
YTDWb.ActiveSheet.Name = Mid(YTDWb.ActiveSheet.Name, 1, 27) + "(4)"
Next sh

What could be my problem? Thanks and God bless for any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default Peculiar Problem when Doing a Sheet.Copy

The sheet copy loop is within another loop that processes more than one
workbook. Thus, the destination workbook is created, then multiple source
workbooks are processed, one by one, copying each sheet in the source into
the destination. If it were just one workbook, then the saveas and rename
would work. What do you mean by a memory issue?
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


" wrote:

POSSIBLY it's a memory issue, but IF all sheets are being copied and
renamed, why not change tack and save the workbook AS a different name
(thus creating another copy) and rename each sheet in this one?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default Peculiar Problem when Doing a Sheet.Copy

Thanks Tom. Will Give it a try!
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Tom Ogilvy" wrote:

Excel seems to have a problem with repetitive copying of sheets.

cnt = TempWb.sheets.count
TempWb.Sheets.copy After:=Workbooks(YTDWbName).Sheets(1)
for i = 2 to cnt + 1
With Workbooks(YTDWbName).sheets(i)
.Name = Mid(.Name, 1, 27) & "(4)"
Next sh
Next

--
Regards,
Tom Ogilvy


"Chaplain Doug" wrote:

Excel 2003. I have some code that copies sheet by sheet from one workbook
into another, renaming the sheets as it goes. Even though the source
workbook has 80 sheets, the copy never gets past the 58th sheet, then errors
out. I have tried using various source workbooks and always bomb at the 58th
sheet. It is not a problem with the sheet being copied. Here is the code:

For Each sh In TempWb.Sheets
'Copy
sh.Copy After:=Workbooks(YTDWbName).Sheets(1)
'Rename
YTDWb.ActiveSheet.Name = Mid(YTDWb.ActiveSheet.Name, 1, 27) + "(4)"
Next sh

What could be my problem? Thanks and God bless for any help.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org

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
Peculiar Date problem Shweta Srivastava77 New Users to Excel 4 May 14th 07 01:32 PM
web query peculiar problem R.VENKATARAMAN Excel Programming 0 September 27th 05 01:21 PM
A peculiar PDF from Excel problem Daniel Bonallack Excel Discussion (Misc queries) 2 March 17th 05 11:23 PM
A peculiar problem Charles Williams Excel Programming 1 July 11th 03 03:52 AM
A peculiar problem Patrick Molloy[_3_] Excel Programming 1 July 10th 03 12:03 PM


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