+ Reply to Thread
Results 1 to 10 of 10

Cycling through files and copying specific/variable ranges to master file

  1. #1
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Cycling through files and copying specific/variable ranges to master file

    Hi All,

    I'm looking to consolidate data from various template files saved within the same folder.

    The aim is to cycle through each file and copy a range of data (some are variable in length) and paste them into the master file on a line by line basis one below the other.

    I've attached a working copy of the master file tab and 3 tabs representing the 3 individual files, the master file is also linked and colour coded to show what i mean.

    Hoping you guys can point me in the right direction.
    Attached Files Attached Files
    Last edited by Gti182; 01-04-2017 at 08:41 AM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Cycling through files and copying specific/variable ranges to master file

    try the following macro which will scan your folder and import your data without opening the files.
    See the attached workbook with the macro in it.
    Please Login or Register  to view this content.
    It might not be great progamming but it works.
    Attached Files Attached Files
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cycling through files and copying specific/variable ranges to master file

    Keeping layout.... row1 lists the cell addresses you want to pull in. So you can change the results of the macro by simply editing the row1 map values. Any cell with a simple address will pull that single cell value. Any cell with an "x" at the end (C19:Cx or D19:Dx) will be treated as a range and multiple rows possibly copied in.

    In the macro, edit the fPATH string to point to the folder where you will be importing all the files:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JBeaucaire; 12-23-2016 at 01:35 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Cycling through files and copying specific/variable ranges to master file

    Thanks for both submissions, away from my computer till the new year but keen to test them as soon as I'm back.

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

    Re: Cycling through files and copying specific/variable ranges to master file

    Since it is the Holiday Season, a couple more to try.
    The workbook with the code in it needs to be (saved) in the same folder as all the workbooks that have the data in it.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    b

  6. #6
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Cycling through files and copying specific/variable ranges to master file

    Thanks for all the submissions. They all work flawlessly as i was hoping and a lot less code than i thought needed.

    Interesting to see 3 different approaches taken.

    To add to the user experience i'm hoping to add the option for the user to select the folder where the files are stored (changes each month) and adding a hyperlink to each row (perhaps to the client name in column B)

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cycling through files and copying specific/variable ranges to master file

    1) macro prompts you to select a folder, it will process all the files within the selected folder.

    2) If the addresses listed in row1 include a cell called Filename then the first instance of each file name will include a Hyperlink.

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

  8. #8
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Cycling through files and copying specific/variable ranges to master file

    Thanks all.

    Managed to give it a go myself with a combination of above code.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Gti182; 01-04-2017 at 05:10 AM.

  9. #9
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Cycling through files and copying specific/variable ranges to master file

    improved this bit of code

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    10-04-2010
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    457

    Re: Cycling through files and copying specific/variable ranges to master file

    double post
    Last edited by Gti182; 01-04-2017 at 08:40 AM. Reason: double post

+ 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. Copying specific cells from different closed workbooks to a Master Excel file
    By kennad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-11-2015, 09:34 AM
  2. Copy specific rows from many files and paste into next empty row in master file
    By Rednalyn in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-08-2013, 09:13 AM
  3. Using a macro to pull specific data from multiple files into a master file
    By bocaj315 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-04-2013, 09:31 AM
  4. [SOLVED] Want to merge specific cells from 1000+ files into one master file
    By dunnybocter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-15-2013, 02:52 AM
  5. Copying data from multiple files in a folder to a master file
    By kjshep in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2012, 12:31 PM
  6. Copy specific cells from many files into master file
    By cmgst49 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2012, 03:05 PM
  7. Replies: 10
    Last Post: 08-22-2012, 09:54 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