Results 1 to 5 of 5

Thread: Excel, save just a single worksheet to new XLS file [resolved]

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Question Excel, save just a single worksheet to new XLS file [resolved]

    How can I, from within the VBA code, save a single worksheet to a new .XLS file?

    I tried the sheet.SaveAs filename method
    but it saves the ENTIRE current file, all sheets and macros etc, into the new file.

    I just want an XLS file with ONE sheet.

    Here's what I'm doing now
    Code:
        Dim NewSheet As Worksheet
        Dim NewSheetName As String
    
        ' Copy the original, target sheet to temp so we can operate on it
        Worksheets(Original_Sheet_Name).Copy after:=Sheets(Sheets.Count)
        Set NewSheet = Worksheets(ActiveSheet.Name)
        NewSheet.Name = NewSheetName
           (do stuff ...)
        NewSheet.SaveAs FileName
    Thanks, DaveBo
    Last edited by DaveBo; Apr 27th, 2004 at 10:37 AM.
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

Posting Permissions

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



Click Here to Expand Forum to Full Width