+ Reply to Thread
Results 1 to 3 of 3

Excel VBA, Consolidate into Master Sheet

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

    Question Excel VBA, Consolidate into Master Sheet

    Hi,

    I'm trying to consolidate multiple workbooks into the a master sheet, and I'm trying to do the following
    Loop through all excel files in directory
    Copy specific cells in Datasheet1 from all excel files and transpose into columns A:C in the mastersheet
    Copy all rows in Datasheet2 from all excel files to the master sheet into columns D:G
    Repeat the transposed cells into all copied rows
    Copy any new data from new sheets into last row+1


    I managed to find the loop function online that serves the purpose, however i'm having trouble with the copy/paste
    Any help is appreciated

    Attached is sample excel for data and mastersheet

    Sample Data:

    File 1 Name: DataFile 1
    Sheet 1: DataSheet1

    Column 1 Column 2
    Name File1 - A
    Number File1 - B
    Data File1 - C

    Sheet2: Datasheet2
    Column 1 Column 2 Column 3 Column 4 Column 5
    File1 - D File1 - E File1 - F File1 - G File1 - H
    File1 - I File1 - J File1 - K File1 - L File1 - M

    All files in the directory have the same structure

    Master Sheet in specified workbook
    Column 1 Column 2 Column 3 Column 4 Column 5 Column 6 Column 7 Column 8
    File1 - A File1 - B File1 - C File1 - D File1 - E File1 - F File1 - G File1 - H
    File1 - A File1 - B File1 - C File1 - I File1 - J File1 - K File1 - L File1 - M
    File2 - A File2 - B File2 - C File2 - D File2 - E File2 - F File2 - G File2 - H


    Please Login or Register  to view this content.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Excel VBA, Consolidate into Master Sheet

    It would be much easier to use Power Query...
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Excel VBA, Consolidate into Master Sheet

    Here's one approach, using Power Query. This uses a Parameters table to store the folder path (you could of course use VBA to edit this value, if you want to use the folder picker dialog)

    There are four queries.

    1. fnGetParameter
    Please Login or Register  to view this content.
    2. fnDataSheet1
    Please Login or Register  to view this content.
    3. fnDataSheet2
    Please Login or Register  to view this content.
    4. CombineAllFiles
    Please Login or Register  to view this content.
    This will combine the data from all files in the folder specified in the parameters table, according to the specification in your first post. Now you can simply "Refresh" the data table, and it will combine the data from all source files.

    See attached file for worked example.
    Attached Files Attached Files

+ 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. Consolidate to Master sheet
    By kannan1847 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-23-2015, 12:52 AM
  2. Automatically consolidate data to one master sheet
    By piyush23y in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2014, 01:11 PM
  3. [SOLVED] Consolidate Dynamic Range from two worksheets into one Master Sheet
    By Laylow in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-12-2013, 09:46 PM
  4. Unable to consolidate all sheet to master sheet
    By sbehera in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2013, 02:48 PM
  5. [SOLVED] Consolidate Data from 1 Range on 1 Sheet in Multiple Workbooks to Master Workbook Sheet
    By Jennasis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2013, 06:11 AM
  6. Consolidate all the sheets into one master sheet
    By vignesh rocks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2013, 08:41 AM
  7. Replies: 0
    Last Post: 07-20-2012, 04:44 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