+ Reply to Thread
Results 1 to 10 of 10

Modification to the Newest file in a folder function - Getting a list of 'n' Newest files

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Mumbai, IN
    MS-Off Ver
    Office 365
    Posts
    97

    Modification to the Newest file in a folder function - Getting a list of 'n' Newest files

    Hi All,

    I have been successfully able to use the Newest File Function to locate the newest file in a given folder. Here is how I use it:

    Please Login or Register  to view this content.
    What I want help with is, to get a list of 'n' number of latest file.

    Idea being the macro downloads a list of CSVs in a list. I use a code to import those files to the active workbook. Doing it one by one is obviously time consuming. Hence, trying to get a list of all those 'N' number in files.

    Please Guide.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    Possibly...
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    09-27-2012
    Location
    Mumbai, IN
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    The code breaks into an error at the line:
    Set Arr = CreateObject("System.Collections.ArrayList")

    -2146232576 - Automation error

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    I've used an Array List many times without a problem... Found this with a google search
    VBA ArrayList Automation Error
    You may encounter the VB Run-time Error ‘-2146232576 Automation Error’ when trying to get the ArrayList to work. Or sometimes your code has been working for a long time and then suddenly this error appears.

    This is caused by not having the correct .Net Framework version installed. The correct version is 3.5. It doesn’t matter if you have a later version like 4.7, you must have 3.5 installed.
    If you can't correct it, let me know and I'll try a different approach.

  5. #5
    Registered User
    Join Date
    09-27-2012
    Location
    Mumbai, IN
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    I Will be able to download the file and install it, but since the file will be shared with other people, there is a chance that they might not have .net 3.5 installed. Hence, I droolingly ask if some another approach can be used. Thanks in advance

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    Not Tested...
    Please Login or Register  to view this content.
    Last edited by dangelor; 08-20-2019 at 07:37 PM.

  7. #7
    Registered User
    Join Date
    09-27-2012
    Location
    Mumbai, IN
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    That does it, however the function quicksort gives me the oldest files. What would be the way to reverse the sorting order?

  8. #8
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-27-2012
    Location
    Mumbai, IN
    MS-Off Ver
    Office 365
    Posts
    97

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    Thank you ever so much Dangelor, you are a star. Sometimes, answers are much simpler than one thinks them to be.

    I was trying to reverse the sorting order, forgetting your approach could be done.

    I appreciate your time and effort in this.

    Marking this thread Solved

  10. #10
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,275

    Re: Modification to the Newest file in a folder function - Getting a list of 'n' Newest fi

    Glad to help and thanks for the feedback!

+ 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] VBA to email newest file in specified folder
    By elmore in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2020, 11:42 PM
  2. Macro to import newest file in folder
    By lofgren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2017, 06:10 AM
  3. [SOLVED] Open newest folder and specific file in the folder
    By timtim91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2017, 11:55 AM
  4. Arranging Pivot table data from Newest to oldest to Newest does not appear
    By paradise2sr in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-08-2014, 06:53 AM
  5. importing the newest file in a folder as text
    By hotwheels in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-06-2011, 08:58 PM
  6. Find newest file in a folder
    By duckboy1981 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2008, 07:32 AM
  7. Moving all but the newest files from one folder to an Archive folder.
    By Zaphius in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2007, 11:48 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