ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting from worksheets into new workbooks (https://www.excelbanter.com/excel-programming/392002-exporting-worksheets-into-new-workbooks.html)

nir020

Exporting from worksheets into new workbooks
 
I have written the following code, which when run, I want to go through all
the sheets in my workbook and and copy and paste the data from these sheets
into new workbooks.

Unfortunatly the code below will cause the data from the same worksheet to
be copied into new workbooks,

Can anyone help

Sub sheetexport()

Dim sheet_var As Worksheet
For Each sheet_var In ActiveWorkbook.Worksheets

Cells.Copy
Workbooks.Add
Application.ScreenUpdating = False
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats

Next
End Sub


Ron de Bruin

Exporting from worksheets into new workbooks
 
Hi nir020

Use this example
http://www.rondebruin.nl/copy6.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"nir020" wrote in message ...
I have written the following code, which when run, I want to go through all
the sheets in my workbook and and copy and paste the data from these sheets
into new workbooks.

Unfortunatly the code below will cause the data from the same worksheet to
be copied into new workbooks,

Can anyone help

Sub sheetexport()

Dim sheet_var As Worksheet
For Each sheet_var In ActiveWorkbook.Worksheets

Cells.Copy
Workbooks.Add
Application.ScreenUpdating = False
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats

Next
End Sub



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com