+ Reply to Thread
Results 1 to 12 of 12

Modify the code to consolidate files in same order as saved in source folder

  1. #1
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Modify the code to consolidate files in same order as saved in source folder

    Hi Guys
    I have this code which consolidates the files from fpath into master file.
    i have 20 files in fpath and i have numbered it from 1 to 20.
    Everytime i run the macro it picks the file in radom order and consilidates it, how to modify it pick in the same order as its being put in the fpath.
    Please Login or Register  to view this content.
    Thanks for any assistance
    Last edited by 6StringJazzer; 08-07-2015 at 10:49 AM. Reason: Moved from Excel General

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify the code to consolidate files in same order as saved in source folder

    The order that files are stored in a Windows folder is undefined. There is no guarantee about how they will be ordered when you retrieve them using Dir.

    If the order is important then you should capture all the file names in an array first, then sort the array by whatever criteria you want to use. Even better, if you have files numbered from 1 to 20, why not just loop through all the file names in that order, instead of using Dir? Do the file names change each time you run this? Using Dir suggests that you don't already know what files are going to be there.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Modify the code to consolidate files in same order as saved in source folder

    Hi i really possess basic knowledge about vba, can you illustrate an example of how i could use an defined array in that code?
    Thanks a lott..

  4. #4
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Modify the code to consolidate files in same order as saved in source folder

    File names remains same. it doesn't change everytime i run the macro

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify the code to consolidate files in same order as saved in source folder

    If you show me what the file names look like I can provide the code changes.

  6. #6
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Modify the code to consolidate files in same order as saved in source folder

    My file name looks like something like this
    1)1.ModelA.Xlsm
    2)2.ModelB.Xlsm
    3)3.ModelC.Xlsm

    and so on till 20th

  7. #7
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Modify the code to consolidate files in same order as saved in source folder

    Hi

    Could you show a syntax change?
    I would be really grateful.

    Thnks for your assistance..

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify the code to consolidate files in same order as saved in source folder

    I have not tested this. It would take some effort to replicate your setup. Please let me know if there are any problems and be specific if something doesn't work.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Modify the code to consolidate files in same order as saved in source folder

    Hi Bro
    Thanks for your help buddy

    I am not able to run this code, its not giving me any error though, nothing happens either when i run it.

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify the code to consolidate files in same order as saved in source folder

    I tested a simplified version and found a bug. Please make the change shown.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    12-11-2014
    Location
    dubai
    MS-Off Ver
    2010
    Posts
    142

    Re: Modify the code to consolidate files in same order as saved in source folder

    Thanks a lot for getting back!!

    It works perfectly fine..thank you soo much!

    Best Regards

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Modify the code to consolidate files in same order as saved in source folder

    You're welcome and thanks for the rep! Please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

+ 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. [SOLVED] Copy certain files from Source folder to Destination folder
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-16-2015, 08:56 PM
  2. [SOLVED] How can I modify this code so that I can only consolidate certain columns?
    By alchavar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-10-2015, 01:10 PM
  3. [SOLVED] How to modify the macro wich summarize all the files from the particular folder?
    By Arty_1 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-17-2015, 08:35 PM
  4. Macro to export excel files from outlook folder and consolidate
    By xxxnac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2014, 02:18 PM
  5. How to Send automated mails with attachment files saved in a folder?
    By yemnirmal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-20-2014, 03:16 PM
  6. copying data from excel files in a source folder to target folder
    By Javed07 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2013, 04:27 PM
  7. modify ALL files in a folder
    By TedH in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-13-2009, 04:53 PM

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