+ Reply to Thread
Results 1 to 3 of 3

In Current workbook- copy sheets from other workbooks and save in current workbook

  1. #1
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    In Current workbook- copy sheets from other workbooks and save in current workbook

    I know how to copy/move sheets from the workbooks where a sheet in the current xlsx is copied to a different workbook, but what I need is to be in the current workbook and copy entre sheets from other workbooks and replace the existing sheets (of same name) in the current xlsm. So that the macros in the MASTER.xlsm will work on the new data.

    These are Excel xlsx exported from QuickBooks Online Enterprise software as reports-- QB will not let me export them into an xlsm file, so we export them each as xlsx.

    Since we do this daily, I would like to automate this process- to replace the old sheets with new sheets of same name.


    Current workbook is: MASTER.xlsm

    Sheets to copy into current Workbook (MASTER) are:
    All Workbooks are in the same directory: x:\documents\QB Excel Report XLSX\
    Sheet "1 OPEN POs" from QBEXPORT OPEN POS.xlsx
    Sheet "2 ITEM LISTING" from QBEXPORT ITEM LISTING.xlsx
    Sheet "3 PENDING BUILDS" from QBEXPORT PENDING BUILD.xlsx
    Sheet "4 ITEM SALES" from SALES BY QBEXPORT ITEM.xlsx
    Sheet '5 TRANSACTIONS" from "QB EXPORT TRANSACTIONS DETAIL.xlsx"

    Thanks,

    J

  2. #2
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Re: In Current workbook- copy sheets from other workbooks and save in current workbook

    I have accomplished this using the "record macro" but there are still 2 issues- both concern prompts that still pop up when I run the macro (even though I answered the prompt when recording the macro)

    1. After I copy a sheet from a workbook to the Master workbook & change the sheet name-- when I close that workbook, prompt still asks "if I want to save any changes."

    2. I delete all sheets in the Master workbook before I copy in the sheets from 5 different workbooks--- prompt asks me "do I want to delete"

    Here is code for 1 of the workbooks....code for the other 4 workbooks is basically same.

    Any help on how to avoid those prompts?

    Thanks,

    J




    Sub Macro1()
    '
    ' Macro1 Macro

    Workbooks.Open Filename:= _
    "C:\Users\jim\Desktop\QB Reports as XLSX\Export to Access PENDING BUILDS.xlsx"
    Sheets("Sheet1").Select
    Sheets("Sheet1").Move After:=Workbooks("MASTER QUICKBOOKS REPORT XLSX.xlsm"). _
    Sheets(1)
    Sheets("Sheet1").Select
    Sheets("Sheet1").Name = "1 PENDING BUILDS"
    Range("N33").Select
    Windows("Export to Access PENDING BUILDS.xlsx").Activate
    ActiveWindow.Close
    Application.WindowState = xlNormal


    Sheets("MAIN MENU").Select

    End Sub

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: In Current workbook- copy sheets from other workbooks and save in current workbook

    1.) When you close the workbook, include the SaveChanges argument.
    ActiveWindow.Close SaveChanges:=True

    2.)Before you delete the sheets, add this line avoid the prompt.
    Application.DisplayAlerts = False
    Then set it back to True after you deleted the sheets.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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. Replies: 0
    Last Post: 07-01-2015, 03:33 PM
  2. VBA code to copy data from current workbook to another workbook and send email
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-05-2015, 06:47 AM
  3. [SOLVED] Copy a Worksheet from a Closed Workbook to the Current Opened Workbook
    By glennchung in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-28-2014, 12:55 PM
  4. Copy sheets from current workbook to another workbook
    By RoMarius1981 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2014, 09:06 AM
  5. Replies: 2
    Last Post: 01-06-2013, 04:27 PM
  6. How to open,save and close another workbook from the current workbook using macro?
    By ravikumar00008 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2012, 10:42 AM
  7. Command button - to copy active sheet and not save current workbook
    By vjboaz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2008, 05:23 PM

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