+ Reply to Thread
Results 1 to 6 of 6

Copy data from 3 separate workbooks into one master file VBA

  1. #1
    Forum Contributor
    Join Date
    02-13-2018
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    179

    Copy data from 3 separate workbooks into one master file VBA

    Hello,

    I am seeking help on a some VBA I wrote to copy selected range, within selected sheet for all workbooks within a file folder.

    Here is what I want to do:

    have the zmaster run a macro to bring in all date from the sheets labeled "Reach". I want columns A-V and then all the way down to the last row of data for each. The amount of data will change very month, so that is why I need to to the last row of data. Then paste all those results from the 3 active workbooks (FS Measures Jan 23, FS Measures Feb 23, FS Measures Mar 23) in the Master starting at A1 on "Sheet1". Here is the code I have so far. However, I get a return error 1004. I would like to be able to rename the workbooks being copied anything I want at any given time. I am not sure why the code is not reading the file names. Workbook is attached.

    Please Login or Register  to view this content.
    Rtn error.PNG

    file path.PNG
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Copy data from 3 separate workbooks into one master file VBA

    Since you are running O365, you have the option of doing this with Power Query. No coding required.

    https://trumpexcel.com/combine-data-...ple-workbooks/
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    02-13-2018
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Copy data from 3 separate workbooks into one master file VBA

    Hi alansidman,

    that did work! However, I want to run a SUMIF formula from one sheet to that new power query table sheet and the formula is returning zero. The calc's are turned on. Do you know why my formula wont pick up any of the data in the table from power query?

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Copy data from 3 separate workbooks into one master file VBA

    Can you be more specific as to what you wish to sum and the criteria for that sum. If I know that, then it is potentially possible to run that calculation within Power Query.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Copy data from 3 separate workbooks into one master file VBA

    If you are looking to sum each column by the file name then you can do a Group BY. I did it for the first three columns after combining the files. If this is not what you are looking for, then explain further.

    Here is the full code and I have highlighted in Red the line that Groups on the file name.

    Please Login or Register  to view this content.
    Excel 2016 (Windows) 64 bit
    A
    B
    C
    D
    1
    Source.Name T1 T2 T3
    2
    FS Measures Feb 23.xlsx
    621
    1242
    1863
    3
    FS Measures Jan 23.xlsx
    923
    1846
    2769
    Sheet: Sheet1

  6. #6
    Forum Contributor
    Join Date
    02-13-2018
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    179

    Re: Copy data from 3 separate workbooks into one master file VBA

    Thanks alansidman, that worked!

+ 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. Updating a workbooks own copy of data from a master file.
    By kadeo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-10-2016, 06:48 AM
  2. Pulling Data from Multiple Workbooks into a Separate Master Workbook
    By awebster in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2016, 01:09 PM
  3. Replies: 2
    Last Post: 09-18-2014, 05:42 AM
  4. Macro to transfer data from multiple workbooks into separate sheets of master file
    By salva7ore in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2014, 08:18 PM
  5. I need to copy data from various workbooks into one master file, specific data
    By madhumith13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-21-2013, 09:14 AM
  6. Exporting data from separate workbooks to master workbook
    By therock1986 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2010, 11:43 AM
  7. Update master workbook data from separate workbooks
    By Deamo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-25-2010, 02:32 AM

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