copy sheet from one workbook to another including formats and values

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,586
Office Version
  1. 365
Platform
  1. Windows
Hi,

Its about 5 years since I did any VBA. How do I copy the contents of one worksheet into another including formats and values ? Here is what I have so far. Thanks

Kaps


HTML:
Sub copy_sheet()
ActiveSheet.CopyWith ActiveWorkbook     .SaveAs Filename:=Environ("TEMP") & "\New1.xls", FileFormat:=5153     .Close SaveChanges:=FalseEnd With
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi, the code you posted just copies the active sheet into a new, separate workbook, then saves it. Are you looking to copy the sheet to a specific workbook?
 
Upvote 0
I'm not incredibly familiar with the fileformat numbers, however assuming it's a valid number I don't see anything inherently wrong. What is the issue with what you posted?
 
Upvote 0
now i have:-

Code:
Option Explicit
Public new_book As Workbook
Public old_Book As Workbook
Sub copy_sheet()




Set old_Book = ActiveWorkbook
Sheets.Copy


Workbooks.Add
Set new_book = ActiveWorkbook


new_book.Sheets(1).Cells(1, 1).PasteSpecial xlPasteValuesAndNumberFormats


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top