+ Reply to Thread
Results 1 to 3 of 3

Save a sheet to a new workbook - Macro

  1. #1
    Registered User
    Join Date
    01-07-2017
    Location
    London
    MS-Off Ver
    Office 2013
    Posts
    10

    Post Save a sheet to a new workbook - Macro

    Hello - I am trying to save specific cells from one workbook into another workbook with the click of a command button.

    I would like to save a specific dynamic area into a new workbook, I have created a new object name for this dynamic table as "Template_Table", so this is the area that needs to be saved into a new workbook ---- I do not know how to implement his part in my code below, any suggestions?

    I would like a dialog to popup to ask the use what they would like to name the new workbook when they click the command button, is this possible?

    I have the code below thus far, but I have an "Run Time 1004, Application Defined or Object Defined Error" -- Any idea what is going on? And how I can fix this?

    Thank you for your help.




    Dim NewName As String
    Dim nm As Name
    Dim ws As Worksheet

    If MsgBox("Copy specific sheets to a new workbook" & vbCr & _
    "Save new workbook as 'H0J0XXXXXX BOM'" _
    , vbYesNo, "Create BOM") = vbNo Then Exit Sub

    With Application
    .ScreenUpdating = False


    On Error GoTo ErrCatcher
    Sheets(Array("BOM")).Copy
    On Error GoTo 0

    ' Paste sheets as values
    ' Remove External Links, Hperlinks and hard-code formulas
    ' Make sure A1 is selected on all sheets
    For Each ws In ActiveWorkbook.Worksheets
    ws.Cells.Copy
    ws.[A1].PasteSpecial Paste:=xlValues
    ws.Cells.Hyperlinks.Delete
    Application.CutCopyMode = False
    Cells(1, 1).Select
    ws.Activate
    Next ws
    Cells(1, 1).Select


    For Each nm In ActiveWorkbook.Names
    nm.Delete
    Next nm


    NewName = InputBox("Please Specify the name of your new workbook", "New Copy")


    ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & ".xls"
    ActiveWorkbook.Close SaveChanges:=False

    .ScreenUpdating = True
    End With
    Exit Sub

    ErrCatcher:
    MsgBox "Specified sheets do not exist within this workbook"

    End Sub


  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,543

    Re: Save a sheet to a new workbook - Macro

    Did you have time to read the forum rules?
    Have a good read, in this case pay special attention to #3.

  3. #3
    Registered User
    Join Date
    01-07-2017
    Location
    London
    MS-Off Ver
    Office 2013
    Posts
    10

    Re: Save a sheet to a new workbook - Macro

    Sorry about that - I thought I had clicked the ##
    I'll repost.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to save more than one sheet in a workbook.
    By Robert1960 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2016, 07:54 AM
  2. macro to copy sheet and save as new workbook
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2015, 08:37 PM
  3. Replies: 1
    Last Post: 10-15-2014, 09:39 AM
  4. MACRO Save As one sheet from workbook
    By forfiett in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2013, 06:20 AM
  5. macro to save sheet from workbook. Specified location and filename
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2011, 11:47 PM
  6. How can I save a single sheet of a workbook using a macro
    By prouddad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2009, 03:02 AM
  7. macro to save to new workbook and clear sheet
    By groundhog in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-26-2007, 01:15 PM

Tags for this Thread

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.6.0 RC 1