saving single worksheet

  • Thread starter Thread starter E.J. van Wijngaarden
  • Start date Start date
E

E.J. van Wijngaarden

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
 
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"
 
Hi,

This will do it.


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

Paul
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top