+ Reply to Thread
Results 1 to 10 of 10

How to make this code work Fast - while handling more data

  1. #1
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Exclamation How to make this code work Fast - while handling more data

    Hi all,

    i have this code to list all the file in the folder and to identify new added one.
    This code works really great when the folder is have files around 200. But this code really get too slow as one of the folder which i mapped got 25000 files.

    could anyone enhance this code to handle this quickly.

    note: i have already tried screen updating false, calculation manual. But still code take around 15 mins to execute and file turn in to not responding. After waiting for quite long time. File lists all the 25000 files.

    help would be much appreciated.

    Attached sample file for your reference.
    Attached Files Attached Files
    Thank you

    If I have helped you in someway, use the * icon below to give reputation feedback, it is appreciated.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How to make this code work Fast - while handling more data

    Maybe it's the deletions try this block deletion:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: How to make this code work Fast - while handling more data

    Ok so I moved the dim statements that belong inside the module, into it...
    I changed your new files listing method, re-using a little bit of your code, but:
    It does not copy all the listed files into new and then compare to clear, instead I filled arrays with the old list and the current list, and added the old files to a dictionary.
    Then we use the dictionary to see if the current files array items are from the old files list, and only if No, do we place it in the new files list.
    See if this works for you:


    Please Login or Register  to view this content.
    Last edited by Arkadi; 10-12-2017 at 04:35 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: How to make this code work Fast - while handling more data

    @xladept, I guess we arrived at the same conclusion for the root of the issue, even if we approached the solution differently

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to make this code work Fast - while handling more data

    This listed 667 files in less than a second:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How to make this code work Fast - while handling more data

    @ Arkadi - looks more like you're between shg and me

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: How to make this code work Fast - while handling more data

    @xladept indeed! I just tackled the main issue while shg was more thorough and wrote a whole new sub that looks to be much more efficient.

    @shg nicely done sir!

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: How to make this code work Fast - while handling more data

    @ Arkadi - Yeah- and I just put a patch in the existing code

  9. #9
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How to make this code work Fast - while handling more data

    Hi all,

    i would like to thank all for your contribution.

    would like to understand code shared by "Shg". i tested the codes, i can see the list of files being published in the first sheet.
    But under header old files it is listing all 10 file names in my folder. And the same list of 10 files being listed under new files header.

    can you please explain for better understanding.

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to make this code work Fast - while handling more data

    When you already have previously listed data on the sheet, just delete column A ("old") and run again. That treats the new column A (which was col B, "current") as "old"

+ 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. Any idea to make this code work faster ( copy and paste data )
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-25-2017, 03:33 AM
  2. [SOLVED] how to make my ThisWorkbook work with my code
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2016, 09:21 AM
  3. [SOLVED] Code is crashing, how can I make this work?
    By liquidmettle in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 01-08-2016, 01:28 AM
  4. Make the below code work faster!!!
    By devpp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2013, 06:13 AM
  5. Replies: 1
    Last Post: 08-14-2013, 12:01 PM
  6. how to make code work
    By Oeysbrei in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2012, 06:22 AM
  7. Fast way to make shortcuts
    By wilro85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-13-2008, 12:04 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