Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to save each sheet as a separate excel-file


Hi, Happy New Year

Could anybody assist me with the code for saving each sheet to a separate
(newly created) file?

So that if I have an excel-file with 20 sheets, I would like a macro to
create 20 separate files.

The new files could get the same names as the sheets (preferably) or the
names could be taken from a cell in the relevant sheet.

Thanks for any help you can give.

Peter

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to save each sheet as a separate excel-file

Assumes the workbook with the 20 sheets has been saved and is not in the
Root directory.

Sub MakeWorkbooks()
Dim sh as worksheet
Dim sStr as String
for each sh in thisworkbook.Worksheets
sh.copy
sStr = ThisWorkbook.Path & "\" & sh.name & ".xls"
On Error Resume Next
Kill sStr
On Error goto 0
ActiveWorkbook.SaveAs sStr, xlWorkbookNormal
ActiveWorkbook.Close Savechanges:=False
Next
End Sub

--
Regards,
Tom Ogilvy


Audio_freak wrote in message
. 2.2...

Hi, Happy New Year

Could anybody assist me with the code for saving each sheet to a separate
(newly created) file?

So that if I have an excel-file with 20 sheets, I would like a macro to
create 20 separate files.

The new files could get the same names as the sheets (preferably) or the
names could be taken from a cell in the relevant sheet.

Thanks for any help you can give.

Peter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to save each sheet as a separate excel-file

Try this Audio_freak

Sub test()
Application.ScreenUpdating = False
For a = 1 To Worksheets.Count
Sheets(a).Copy
ActiveWorkbook.SaveAs Sheets(1).Name
ActiveWorkbook.Close
Next a
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Audio_freak" wrote in message . 2.2...

Hi, Happy New Year

Could anybody assist me with the code for saving each sheet to a separate
(newly created) file?

So that if I have an excel-file with 20 sheets, I would like a macro to
create 20 separate files.

The new files could get the same names as the sheets (preferably) or the
names could be taken from a cell in the relevant sheet.

Thanks for any help you can give.

Peter



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to save each sheet as a separate excel-file


Works !

Thanks!!






"Tom Ogilvy" wrote in
:

Assumes the workbook with the 20 sheets has been saved and is not in
the Root directory.

Sub MakeWorkbooks()
Dim sh as worksheet
Dim sStr as String
for each sh in thisworkbook.Worksheets
sh.copy
sStr = ThisWorkbook.Path & "\" & sh.name & ".xls"
On Error Resume Next
Kill sStr
On Error goto 0
ActiveWorkbook.SaveAs sStr, xlWorkbookNormal
ActiveWorkbook.Close Savechanges:=False
Next
End Sub

--
Regards,
Tom Ogilvy


Audio_freak wrote in message
. 2.2...

Hi, Happy New Year

Could anybody assist me with the code for saving each sheet to a
separate (newly created) file?

So that if I have an excel-file with 20 sheets, I would like a macro
to create 20 separate files.

The new files could get the same names as the sheets (preferably) or
the names could be taken from a cell in the relevant sheet.

Thanks for any help you can give.

Peter




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to save each sheet as a separate excel-file


En deze werkt ook ! Stukje korter zelfs.

Dank !!





"Ron de Bruin" wrote in news:#hFAyuv0DHA.2856
@TK2MSFTNGP09.phx.gbl:

Try this Audio_freak

Sub test()
Application.ScreenUpdating = False
For a = 1 To Worksheets.Count
Sheets(a).Copy
ActiveWorkbook.SaveAs Sheets(1).Name
ActiveWorkbook.Close
Next a
Application.ScreenUpdating = True
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Split text file into Excel sheet and separate the final results intoa new sheet Luciano Paulino da Silva Excel Worksheet Functions 8 April 18th 09 02:00 AM
How do I save a page in a workbook as a separate file? flowv Excel Worksheet Functions 4 January 22nd 09 02:52 PM
How do I save part of a worksheet in a separate file? cleo Excel Worksheet Functions 3 May 15th 07 01:26 AM
Can I auto save to a separate file?(not the file I am working in) Jim Lynch Setting up and Configuration of Excel 1 August 14th 06 05:20 PM
Excel kept on asking to save file every time I jump from one sheet to another! [email protected] Excel Worksheet Functions 8 March 31st 06 03:37 AM


All times are GMT +1. The time now is 06:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"