ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   saving single worksheet (https://www.excelbanter.com/excel-programming/294761-saving-single-worksheet.html)

E.J. van Wijngaarden

saving single worksheet
 
Hello,

I want to save one worksheet of a workbook as a separate xls-file.
I use: Worksheets("test").SaveAs "test1.xls".

According to the help this should do the job.
But everytime the whole workbook is saved, including all other worksheets.
How to solve this?

Thanks for your answer.

Ed van Wijngaarden



Ron de Bruin

saving single worksheet
 
Hi E.J.

' copy the sheet to a new workbook
Worksheets("test").Copy
' save the worbook with only the sheet test
ActiveWorkbook.SaveAs "C:\test1.xls"


--
Regards Ron de Bruin
http://www.rondebruin.nl


"E.J. van Wijngaarden" wrote in message ...
Hello,

I want to save one worksheet of a workbook as a separate xls-file.
I use: Worksheets("test").SaveAs "test1.xls".

According to the help this should do the job.
But everytime the whole workbook is saved, including all other worksheets.
How to solve this?

Thanks for your answer.

Ed van Wijngaarden





Paulw2k

saving single worksheet
 
Hi,

This will do it.


Sub SaveTestSheetSeparately()
Worksheets("test").Copy
ActiveWorkbook.SaveAs "test1.xls"
End Sub

Paul

"E.J. van Wijngaarden" wrote in message
...
Hello,

I want to save one worksheet of a workbook as a separate xls-file.
I use: Worksheets("test").SaveAs "test1.xls".

According to the help this should do the job.
But everytime the whole workbook is saved, including all other worksheets.
How to solve this?

Thanks for your answer.

Ed van Wijngaarden





E.J. van Wijngaarden

saving single worksheet
 
Thanks for both answers.

I changed the code to:

Sub SaveTestSheetSeparately()
Application.ScreenUpdating = False
Worksheets("test").Copy
ActiveWorkbook.SaveAs "test1.xls"
ActiveWorkbook.Close
Application.ScreenUpdating = True
End Sub

Now it does exactly what I want.

Ed




All times are GMT +1. The time now is 04:31 AM.

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