+ Reply to Thread
Results 1 to 19 of 19

VBA merge worksheets in a folder - each file in a column, multiple worksheets below

  1. #1
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    I am more or less using Ron's VBA code to pull data from a worksheet in each file in the folder. It is working just fine. I want to expand this by having it take data from multiple worksheets in each file and put them underneath each other - file 1 would be in column A, file 2 column B (just like the regular code), but in column A it would have the data range from sheet 1, then the data range from sheet 2 below that, and on. Thoughts on what to add to the following?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by bigmantitus; 02-11-2021 at 01:03 PM.

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    It would help if you could load a sample file, as per the yellow banner above.

  3. #3
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Sample file attached.

  4. #4
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Give this code a try

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Thanks for reply. This works great for stacking the data in a single column. I am looking for more of a combination of the two approaches. Everything from file one goes in column A, file 2 goes to column B. But the data from each worksheet is stacked in the column.

  6. #6
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    So your saying that there are multiple worksheets in each workbook? Which worksheets do you need to copy over, all of them, or just the first two, or just certain named ones, or all but not one with a certain name? It's not clear from the sample workbook.

  7. #7
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    That is correct. There are two worksheets in each workbook that need to be copied over one above the other (call them sheet Content and Progress). Each workbook would then be in a different column.

  8. #8
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Alright, here is an update

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Thank you for the update. It works great. There are a few adds I would like to make -

    - The two worksheets (content/process) have different ranges to pull from
    - The worksheet names are four words separated with _ (i.e. A_B_C_D). Can it pull the worksheet name and split up the values? So A would be row 1, B row 2, etc)
    - Rather than copy into a new worksheet starting in column A, I would rather it pull all the data into an already existing worksheet in the current file (that has the VBA code) starting in column B (so that I can have column A prepopulated)

    Thanks again!

  10. #10
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    We need to see the new file setup. Where are the ranges on the sheet?

  11. #11
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Call it B2:B4 on the content sheet, B2:B6 on the process sheet. The row value will likely change as I finalize the pull in data.

  12. #12
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    The data being pulled is already in column B. Please create a sample workbook that is representative of your new requirements, with before and after sheets

  13. #13
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Updated with attached file.
    Attached Files Attached Files

  14. #14
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    The file does not align to the description in post #9.

  15. #15
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Updated file attached.
    Attached Files Attached Files

  16. #16
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Try this code. There is a worksheet titled Summary where the data will populate.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by maniacb; 02-10-2021 at 12:37 AM.

  17. #17
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    This seems to work very well, thanks. The only issue I am seeing is that the file names that it pulls in (A_B_C_D) need to be of the files being merged in, not the name of the current file open. For example, A, B, C, D will be different for each file pulled.

  18. #18
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Updated

    Please Login or Register  to view this content.
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    09-14-2012
    Location
    Denver, CO
    MS-Off Ver
    Excel 2007
    Posts
    66

    Re: VBA merge worksheets in a folder - each file in a column, multiple worksheets below

    Seems to work great! Thanks again for all of the help.

+ 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: 04-18-2019, 09:13 AM
  2. merge multiple worksheets based on values in column
    By sacwgar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2015, 11:24 AM
  3. merge all worksheets from all XL files in selected folder
    By karthikthandapani in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-22-2014, 04:29 PM
  4. [SOLVED] Merge Multiple Worksheets to One
    By Dnass in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-05-2013, 10:08 PM
  5. [SOLVED] Index all Worksheets in All Workbooks in a Folder with Hyperlink to File
    By lesoies in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-15-2012, 12:44 AM
  6. Merge several worksheets into the same .csv file
    By NiceLittleRabbit in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2011, 06:38 AM
  7. Split out worksheets then merge into master file
    By pixifaery in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-27-2010, 06:59 AM

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