+ Reply to Thread
Results 1 to 9 of 9

Copy/Paste from multiple wbks same folder

  1. #1
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Copy/Paste from multiple wbks same folder

    I am trying to create a document that will pull Rows 16 & 79 from ALL the other workbooks in the folder my Summary document is in - not looking to make it a specific folder because I have multiple folders with various files (i.e. Blue files, Red files, Yellow files, etc). I'll just drop my Summary file in the folder I need, run it and then grab the info before I drop it into another folder.

    I found a few different solutions but they all seem to want to look in a specific folder. I also would like it to jump rows when it's pasting from each book. I created a template of the Summary file I'd ideally like to put together.

    The books it will pull from will always have the same sheet name, although there won't always be 20 of them - I just picked the largest number would be in any one folder.

    Any help would be appreciated.
    Attached Files Attached Files

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

    Re: Copy/Paste from multiple wbks same folder

    See how far this gets you.
    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,539

    Re: Copy/Paste from multiple wbks same folder

    .......................
    Last edited by jindon; 04-11-2024 at 11:48 PM.

  4. #4
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Copy/Paste from multiple wbks same folder

    jolivanes - I've modified your macro a bit but overall I really like it. It even labels Col A by using my file names - I only used Book 1-8 as default names. This is a step I would've done later, so time saved

    I did notice something that I'm sure is an easy fix that is just going over my head at the moment.
    1. Instead of taking the data from Jan 24-Dec 24 (in blue on Book1), it's taking Jan 23-Nov 23 (in yellow on Book1) + the Row heading from Col B (both happened to be "PSIH"). Ideally it would match the dates from Row 1 on Summary and Row 3 on the books in the folder and bring back the applicable data from Rows 16 and 79.

    I've provided a stripped down version (taking out sensitive data) of one of the books I'll actually be using.
    Attached Files Attached Files

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

    Re: Copy/Paste from multiple wbks same folder

    Your original Book1 and this Book1 are two different animals.
    The first book has only data in Columns B to M (2 to 13) while the new Book 1 is from C to EB (3 to 132)
    In the original, data was transferred from Row 16 in Column B and resized to Column M
    In this line (owb.Sheets("Sheet1").Cells(16, 2).Resize(, 12).Value), the "Cells(16, 2)" means Row 16 and Column 2 = Column B
    So if it is not the second Column, change the 2 to the Column you need to work with, according to your last Post that would be Column O which is Column 15.
    Change the 2 to a 15 and that should get you the right range. You also need to change it in the line for the other row of course.

    Re: "Ideally it would match the dates from Row 1 on Summary and Row 3 on the books in the folder and bring back the applicable data from Rows 16 and 79."
    I'll have a look into that later when more time.

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

    Re: Copy/Paste from multiple wbks same folder

    To solve this "Ideally it would match the dates from Row 1 on Summary and Row 3 on the books in the folder and bring back the applicable data from Rows 16 and 79."


    Check and change references like sheet names where required.

    Insert "Dim col As Long" somewhere with all the other Dim statements.

    Insert the col line below the Workbooks open line like so
    Please Login or Register  to view this content.
    Change all the Column references for the workbook where the data is coming from.
    Where it had a 2 previously and was changed in the last Post to a 15, now change these numbers to "col" (without double quotes), so they will become
    Cells(16, 2) or Cells(16, 15) will become Cells(16, col)
    Cells(79, 2) or Cells(79, 15) will become (Cells(79, col)

  7. #7
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Copy/Paste from multiple wbks same folder

    Thank you very much jolivanes! While I haven't implemented your solution to my date matching yet , your explanation of how to change the columns I'm looking at worked perfectly. And I thank you for explaining how that change works so I will learn in the future.

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

    Re: Copy/Paste from multiple wbks same folder

    Thanks for the update and good luck.

  9. #9
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    327

    Re: Copy/Paste from multiple wbks same folder

    Thanks! Works great and I've learned more from studying what you provided.
    Last edited by Wheelie686; 04-18-2024 at 08:58 PM.

+ 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. VBA C_Paste range from one wbks with multiple ws to multiple wbks and multiple ws
    By jackdaniel99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2020, 10:02 AM
  2. [SOLVED] copy/paste from multiple files in a folder to single workbook
    By HXIO in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-06-2019, 01:57 PM
  3. [SOLVED] Loop formula to copy and paste worksheet from multiple workbooks within same folder
    By Learning2Code in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-23-2019, 11:08 AM
  4. [SOLVED] Copy range of data from all workbooks in folder and paste to multiple sheets in new book
    By Brontosaurus in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2019, 08:52 AM
  5. open folder has multiple worksheets ,copy specific data from a tab and paste them
    By Khaled Diab in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2014, 05:27 AM
  6. Copy a Template workbook ans paste in a multiple Files in a Folder
    By arvind1979_3 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-24-2013, 09:07 AM
  7. copy & paste data from multiple workbooks to new workbook in a folder
    By Ignesh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2012, 03:11 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