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: 96
Default Copy Worksheet Between Books and Retain Formatting

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
 
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
Copy Header/Footer to Retain Formatting Jill E. Lingle Excel Discussion (Misc queries) 3 March 3rd 08 06:36 PM
copy/paste want to retain cell coloration but lose the conditional formatting source data Keith R Excel Discussion (Misc queries) 6 March 5th 07 09:10 PM
retain formatting as an actual value Terri Excel Worksheet Functions 4 December 12th 05 09:21 PM
How do I copy and paste Excel charts and retain formatting? Mine . Ivan Lawler Charts and Charting in Excel 2 February 17th 05 01:53 PM
how do I make a copy of a worksheet and retain formulas but not data FireBrick Setting up and Configuration of Excel 2 December 29th 04 07:33 PM


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