PC Review


Reply
Thread Tools Rate Thread

Copy Worksheet Between Books and Retain Formatting

 
 
PatK
Guest
Posts: n/a
 
      1st Jun 2009
I have the following code that copies a specific worksheet from one workbook,
to another. Problem is, that the format of the worksheet is lost during the
copy. Is there a way to make sure that, when copied, the worksheet I have
just pasted looks exactly like the original?

Thanks for any help! Patk

Sub SheetCopyBetweenFiles(sourcefile, destfile, sheetnametocopy, aftersheet)

Dim srcbook, destbook As Workbook
Dim copysheet, newsheet As Worksheet

Workbooks(sourcefile).Activate
Set srcbook = ActiveWorkbook
Set copysheet = srcbook.Worksheets(sheetnametocopy)
Set destbook = Workbooks(destfile)

With destbook
.Worksheets.Add after:=.Worksheets(.Worksheets.Count)
.ActiveSheet.Name = sheetnametocopy
copysheet.Cells.Copy .Worksheets(.Worksheets.Count).Cells

End With
Set srcbook = Nothing
Set copysheet = Nothing
Set destbook = Nothing
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Header/Footer to Retain Formatting Jill E. Lingle Microsoft Excel Misc 3 3rd Mar 2008 06:36 PM
Retain formatting when I copy and paste in PowerPoint =?Utf-8?B?RUVPY2hzbmVy?= Microsoft Powerpoint 3 11th Apr 2005 10:34 PM
How do I copy and paste Excel charts and retain formatting? Mine . =?Utf-8?B?SXZhbiBMYXdsZXI=?= Microsoft Excel Charting 2 17th Feb 2005 01:53 PM
how do I make a copy of a worksheet and retain formulas but not data FireBrick Microsoft Excel Setup 2 29th Dec 2004 07:33 PM
Retain formatting during copy-and-paste Bobby Microsoft Word Document Management 1 19th Sep 2004 10:37 PM


Features
 

Advertising
 

Newsgroups
 


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