copy sheet from one workbook to another including formats and values

Kaps_mr2

Well-known Member
Joined
Jul 5, 2008
Messages
1,589
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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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