Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Jul 2003
    Location
    Amarillo, Texas, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving Sheets as Files (Excel 2000)

    I have spreadsheets with multiple sheets. I would like to save each sheet as an individual file using the sheet name as the file name. Any ideas to help me get started? Thanks.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving Sheets as Files (Excel 2000)

    This should do what you want:

    <pre>Public Sub SaveSheets()
    Dim oNewWB As Workbook, oCurWB As Workbook, oWS As Worksheet
    Dim lNunSheets As Long
    Dim strFileName As String
    lnumsheets = Application.SheetsInNewWorkbook
    Application.SheetsInNewWorkbook = 1
    Set oCurWB = ActiveWorkbook
    For Each oWS In oCurWB.Worksheets
    strFileName = "C:Test" & oWS.Name & ".xls"
    Set oNewWB = Workbooks.Add
    oWS.Cells.Copy
    oNewWB.Sheets(1).Paste Destination:=Sheets(1).Range("A1")
    oNewWB.SaveAs Filename:=strFileName
    oNewWB.Close
    Set oNewWB = Nothing
    Next oWS
    Set oWS = Nothing
    Set oCurWB = Nothing
    Application.SheetsInNewWorkbook = lnumsheets
    End Sub
    </pre>

    Legare Coleman

  3. #3
    New Lounger
    Join Date
    Jul 2003
    Location
    Amarillo, Texas, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving Sheets as Files (Excel 2000)

    Thanks --- This works great.

    BigJohn2

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving Sheets as Files (Excel 2000)

    Hi Legare,

    You can also add a one-sheet workbook like this:

    Workbooks.Add xlWorksheet
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving Sheets as Files (Excel 2000)

    Thanks, I hadn't seen that one.
    Legare Coleman

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Saving Sheets as Files (Excel 2000)

    You could also take advantage of the fact that the Worksheet Copy method copies the worksheet object to a new file unless the Before or the After parameters are specified. The following code should then create a new file file for each sheet in the workbook in which it is contained.<pre> Sub SaveSheets()
    Dim oWB As Workbook, intWS As Integer
    Set oWB = ThisWorkbook
    For intWS = 1 To oWB.Sheets.Count
    oWB.Sheets(intWS).Copy
    ActiveWorkbook.SaveAs Filename:=ActiveSheet.Name
    Next
    End Sub</pre>


    Andrew C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •