copy sheet from one workbook to another including formats and values

Kaps_mr2

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

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

KennyGreens

Board Regular
Joined
Aug 8, 2018
Messages
142
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?
 

KennyGreens

Board Regular
Joined
Aug 8, 2018
Messages
142
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?
 

Kaps_mr2

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

Watch MrExcel Video

Forum statistics

Threads
1,122,232
Messages
5,594,962
Members
413,954
Latest member
mrsandy

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
Top