+ Reply to Thread
Results 1 to 4 of 4

Thread: Pull 2 Worksheets Out of Workbook, Make It Their Own Workbook

  1. #1
    Registered User
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    71

    Pull 2 Worksheets Out of Workbook, Make It Their Own Workbook

    As the title suggests, I am looking to pull two worksheets out of a workbook and make only those two sheets into their own workbook. Everything inside of the worksheets including all formulas and script will need to go with them, if that matters...

    Call the sheets A and B

    The tab titles of the sheets in the new workbook will not change, but the title of the workbook will be based on a variable in a cell in worksheet A

    The workbook will also be saved on another computer on the network, on the desktop of a computer named "computer 2"

    I poked around, but couldn't combine enough responses based on what I was looking for to come up with a working model.

    Thanks in advance.

  2. #2
    Valued Forum Contributor
    Join Date
    03-13-2004
    Location
    Gothenburg/Stockholm, Sweden
    MS-Off Ver
    Excel 2003 and reluctantly Excel 2007
    Posts
    631

    Re: Pull 2 Worksheets Out of Workbook, Make It Their Own Workbook

    Perhaps something like this?

    Sub test()
    Sheets("A").Activate
    ActiveSheet.Copy
    ActiveWorkbook.SaveAs Filename:="C:\SomeFolder\Whatever.xls"
    ActiveWorkbook.Close
    End Sub
    If you uploaded an example file you would probably get a better answer.

    Alf

  3. #3
    Registered User
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    71

    Re: Pull 2 Worksheets Out of Workbook, Make It Their Own Workbook

    file attached.

    Thank you.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-30-2011
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    71

    Re: Pull 2 Worksheets Out of Workbook, Make It Their Own Workbook

    I got what I wanted with this. I still need to make some tweaks to it, but maybe someone can benefit from this.

    Sub Make_New_Book()
    
    Dim DstFile As String 'Destination File Name
    Dim TD As String 'To date
        TD = Range("A2").Value
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    Dim wb As Workbook
     
    Sheets(Array("A", "B")).Select
    Sheets("B").Activate
    Sheets(Array("A", "B")).Copy
     
    Set wb = ActiveWorkbook
       
        DstFile = Application.GetSaveAsFilename _
        (InitialFileName:="C:\Documents and Settings\MyName\Desktop\Daily " & TD & ".xls", _
        Title:="Save As")
        If DstFile = "False" Then
            MsgBox "File not Saved, Actions Cancelled."
            Exit Sub
        Else
            wb.SaveAs DstFile 'Save file
            wb.Close 'Close file
        End If
       
        MsgBox ("File Saved")
    
    Application.ScreenUpdating = True
    ActiveWorkbook.Save
    Application.DisplayAlerts = False
    
    Application.Quit
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0