+ Reply to Thread
Results 1 to 13 of 13

Continuously combine all excel files in a folder

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    long beach
    MS-Off Ver
    Excel 2010
    Posts
    18

    Continuously combine all excel files in a folder

    Hi all,

    I have a small company that receives orders via an excel file. The excel order forms are always exactly same. I've attached an example order form. These orders all go into one folder. I need to keep track of how much we are selling of each item in a master excel file. Is there a way to extract the data from each file in the folder and add it together into a master excel file? This needs to be a simple solution, since we are continuously receiving orders and need to continuously update this master file.

    Thanks in advance for the help,
    Kyle

    Order Form.xlsx

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

    Re: Continuously combine all excel files in a folder

    This is a common task, so no problem about actually doing it. To make this easiest to get right the first time, please provide the following.

    1) 2-3 good sample orders.
    2) 1 MASTER file showing the layout of your desired summary. This layout should include a manual mockup of the information from the 2-3 sample orders so we can see exactly how the sample data should be represented in your master.
    3) The name of the folder on your system where these folders will be found

    --------
    When importing files into a consolidation file (master), to keep from importing the same file more than once we need to do one of these:

    a) move the imported files into another folder
    b) change the name of the import file in a way that make it obvious the file has been imported (for example file1.xlsx becomes file1().xlsx)
    c) write a flag into each file that marks the file as imported.

    Those options are listed in order of my personal preference, a) is good because if you ever need to "start over", you simply move all the files from the "done" folder back into the main folder and they would be imported again into the new master.
    _________________
    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!)

  3. #3
    Registered User
    Join Date
    08-19-2012
    Location
    long beach
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Continuously combine all excel files in a folder

    Hi JBeaucaire,

    Thanks for the help. Attached are the requested files. I have made a quick master file but the layout will likely need to change a bit in the future. The name of the folder the files are in is called order form. I will likely go with your first suggestion for separating the imported files by having a folder in the order forms folder that has the files that haven't been imported called import.

    Thanks again,
    Kyle

    Order Form ex3.xlsxOrder Form ex2.xlsxOrder Form ex1.xlsxMaster.xlsx

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

    Re: Continuously combine all excel files in a folder

    Ok, would have been much easier if the MASTER was the exact same positions as the order forms, but you did mention the master may need to be adjustable. This forced me to "match" the row and columns of the items to update to the master positions of the same items.

    For this macro to keep functioning, there must be cells with

    Product #
    Ral #


    ...so those columns and rows can be found. In the order form sheets we need cell that have:

    Product #
    Ral #
    Shipping


    ...so the data range can be spotted.

    The macro is installed into the master.

    You will need to edit the macro to list the folder addresses to the \IMPORT\ folder and the \MAIN\ folder where the files should go when done.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JBeaucaire; 08-15-2015 at 08:39 PM.

  5. #5
    Registered User
    Join Date
    08-19-2012
    Location
    long beach
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Continuously combine all excel files in a folder

    Hi JBeaucaire,

    Thanks for this. Looks great. I'm trying to implement it and am getting an run-time error code 68. The debugger highlights: fNAME = Dir(fPATH & "*.xlsx") 'get the first filename for import". I'm guessing I have the folder directories entered in incorrectly. I am on a mac, so maybe that is the problem? This is what I have entered for the directories:

    fPATH = "untitled/Users/kylemccoy/Google Drive/Blocz/Orders/New/" 'don't forget the final \ in this folder string
    fMAIN = "untitled/Users/kylemccoy/Google Drive/Blocz/Orders/" 'don't forget the final \ in this folder string

    Also, when opening the master file it wants to update links but I'm guessing this is from the example order forms.

    -Kyle

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

    Re: Continuously combine all excel files in a folder

    Update links? Yes, I would presume you want to start with a blank master.

    I don't really have any MAC conversion tips. Sorry.

  7. #7
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Continuously combine all excel files in a folder

    I have no MAC experience, but the following link (with sample code) indicates that you may have to add a MacID to the Dir() command: http://stackoverflow.com/questions/1...excel-2011-vba

    In addition the Path Separator on a Mac is apparently the colon. See http://stackoverflow.com/questions/1...pc-but-not-mac

    The above statements are verified by Microsoft (in the Remarks paragraph) at:
    https://support.office.com/en-us/art...rs=en-US&ad=US

    Sample Dir() code for MAC courtesy of Ron de Bruin:
    http://www.rondebruin.nl/mac/mac013.htm

    Unrelated example MAC VBA code:
    https://msdn.microsoft.com/en-us/lib...ice.14%29.aspx
    http://www.rondebruin.nl/mac/section3.htm

    I hope all this points you in the right direction.

    Lewis
    Last edited by LJMetzger; 08-17-2015 at 08:49 AM.

  8. #8
    Registered User
    Join Date
    08-19-2012
    Location
    long beach
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Continuously combine all excel files in a folder

    Thanks Lewis for those sources. I think I'm getting closer but am still getting the error code 68 "device unavailable". Anyone have any ideas? Below is the code I'm trying:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-18-2015 at 09:53 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

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

    Re: Continuously combine all excel files in a folder

    Don't forget CODE tags when posting VBA code. I've added it for you this time above.

    When you DEBUG at that error, which line is highlighted?

  10. #10
    Registered User
    Join Date
    08-19-2012
    Location
    long beach
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Continuously combine all excel files in a folder

    Oh, sorry didn't see the code tags. Now I do.

    The line it's highlighting is:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 08-18-2015 at 11:16 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

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

    Re: Continuously combine all excel files in a folder

    I've added coded tags for you again.

    https://support.office.com/en-us/art...rs=en-US&ad=US

    Based on that "XLSX" is not the correct thing to search for, MacID does not search for the listed text, it searches for the designated file type. From the link above that would appear to be "XLS5"

  12. #12
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Continuously combine all excel files in a folder

    Just a guess but try:
    Please Login or Register  to view this content.
    For examples see: See http://gotoanswer.com/?q=Loop+throug...r+using+VBA%3F

  13. #13
    Registered User
    Join Date
    08-19-2012
    Location
    long beach
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Continuously combine all excel files in a folder

    I tried the below code and didn't receive an error this time but also didn't get any data imported into the master file.

    Please Login or Register  to view this content.
    I tried making sure the source import files all had the column text "Product #", "Ral #" & "Shipping" but still no data. I did notice the Master file doesn't have a "shipping" cell/column (maybe this is the problem?). I also checked the folder paths and couldn't find anything wrong. Seems like we are getting closer but there's something I'm missing.

    I'm attaching the files again. Thank you all for your help. It's greatly appreciated.

    Master-1.xlsmOrder Form ex3.xlsxOrder Form ex2.xlsxOrder Form ex1.xlsx

+ 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. Open Folder Dialog Box with Combine Files Code
    By wealthistime in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-15-2015, 08:47 PM
  2. Replies: 3
    Last Post: 02-13-2015, 10:09 PM
  3. Combine Data from Closed Files within the same folder
    By lasjbp9 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2013, 10:07 AM
  4. Folder Dialog Box with Combine Files Code
    By wealthistime in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2011, 05:43 AM
  5. Replies: 1
    Last Post: 01-24-2006, 11:35 AM
  6. Replies: 1
    Last Post: 01-24-2006, 11:00 AM
  7. Replies: 1
    Last Post: 01-24-2006, 12:25 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