Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Copying Sheets to New workbooks

Hi All,
I am using the following code to copy a sheet two sheets to new workbooks
(seperate workbooks):-
sheets("Sheet1").copy
sheets("Sheet2").copy

This does not work as some of the cells contain more than 255 characters.

I want two copy sheet1 and sheet2 to two new workbooks respectively.

I then want to save each of them in the format Sheet_1_MONTH where MONTH is
the month the file is saved in.

Any help or pointers would be helpful.

Thanks

Andi


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Copying Sheets to New workbooks

Sorry - When I say doesn't work I mean it comes up with error "Run-time
error '-2147352565 (8002000b)': The sheet you are copying has cells that
contain more than 255 characters. When you copy the entire sheet, only the
first 255 characters in each cell are copied.

To copy all of the character, copy the cells to a new sheet instead of
copying the entire sheet."

Having thought about it, maybe a bit of error handling would sort it out.
Not sure though...

"Andibevan" wrote in message
...
Hi All,
I am using the following code to copy a sheet two sheets to new workbooks
(seperate workbooks):-
sheets("Sheet1").copy
sheets("Sheet2").copy

This does not work as some of the cells contain more than 255 characters.

I want two copy sheet1 and sheet2 to two new workbooks respectively.

I then want to save each of them in the format Sheet_1_MONTH where MONTH

is
the month the file is saved in.

Any help or pointers would be helpful.

Thanks

Andi




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Copying Sheets to New workbooks

"Andibevan" wrote in message
...
Hi All,
I am using the following code to copy a sheet two sheets to new workbooks
(seperate workbooks):-
sheets("Sheet1").copy
sheets("Sheet2").copy

This does not work as some of the cells contain more than 255 characters.


Hi Andi,

To get around this problem you need a two-step process. First copy the
worksheet itself (and let all cells with more than 255 characters get
truncated), then copy the contents of the worksheet and paste them into the
copy. Here's one way of doing it:

Sub CopySheets()

Dim wkbBook As Workbook
Dim wksSheet As Worksheet

Set wkbBook = ActiveWorkbook

Set wksSheet = wkbBook.Worksheets("Sheet1")
wksSheet.Copy
wksSheet.Cells.Copy ActiveSheet.Range("A1")

Set wksSheet = wkbBook.Worksheets("Sheet2")
wksSheet.Copy
wksSheet.Cells.Copy ActiveSheet.Range("A1")

End Sub

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


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
Copying Sheets between workbooks without links Air-ron Excel Discussion (Misc queries) 3 February 25th 09 09:03 PM
copying workbooks acomputer4u Excel Worksheet Functions 3 November 25th 06 06:29 PM
Copying workbooks Nadji New Users to Excel 4 October 5th 06 03:16 PM
Copying from other Workbooks SusieQ Excel Discussion (Misc queries) 0 January 30th 06 12:44 PM
Copying from several workbooks into one Anthony Gobel Excel Programming 0 April 6th 04 09:56 PM


All times are GMT +1. The time now is 09:08 PM.

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"