+ Reply to Thread
Results 1 to 8 of 8

Folder Picker - picking files in chronological order

  1. #1
    Registered User
    Join Date
    06-11-2014
    Posts
    20

    Exclamation Folder Picker - picking files in chronological order

    Hello,

    I am a beginner working with VBA. Wondering if it is possible to have files within a designated folder open in chronological order (by date).

    I am incorporating the FileDialogFolderPicker for the following sequence:

    - I select the folder path. Each folder contains files for each day of the month, and they are number accordingly: 20150101, 20150102, 20150103, etc.

    - I click a button, the prompt comes up to select a folder, I select the folder, then the macro opens each file, copies a specified range of data, pastes that data into a sheet in a different designated workbook, then closes the workbook it just opened. It does this sequence for each file one by one, so that a file is closed before the next one is opened.

    - The macro works smoothly. The data is pasted starting in the first row of the worksheet, and going down. The only issue is that the data that is copied and pasted into the specified sheet is not pasted in chronological order. The "data" that I am referring to are tables - tables of data that are all being pasted into one sheet. Example: there is a table for July 1 2014, July 2 2014, July 3 2014, etc., and each table is 10 rows thick, and 10 rows long.

    All i need is for the tables of data to appear in order by date (within the sheet where I am consolidating them). I have not been able to find specific code that will execute this in order.

    Thank you!!!


    - J
    Last edited by jcroque89; 01-27-2015 at 07:07 PM. Reason: to add tags

  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: Folder Picker - picking files in chronological order

    You could list them and sort them before you open them:

    To list them something like this:

    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
    Registered User
    Join Date
    06-11-2014
    Posts
    20

    Re: Folder Picker - picking files in chronological order

    I tried the code and it listed the file names in excel. Would I then run a macros to open the files in this order from excel?

    The files that I am opening (by referencing the folder) are in order within the folder (organized by date), but are opening in a random order. Is there a way I could get them to open from the 1-30 in order?

    Thank you.

    - J

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

    Re: Folder Picker - picking files in chronological order

    Hi J,

    Yes - sort them in the order that you want and then open them in that order from your sorted list

  5. #5
    Registered User
    Join Date
    06-11-2014
    Posts
    20

    Re: Folder Picker - picking files in chronological order

    Great! Thank you.

    For future reference - is there a way to do this in the target folder itself? So I could sort the files (by name) directly in the target folder, then pull them for editing.

    Thank you,


    - J

  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: Folder Picker - picking files in chronological order

    Hi J,

    Thanks for the rep!

    Manually, with the folder open, you can click on the date modified tab.

    (I don't know how to do it with code)

  7. #7
    Registered User
    Join Date
    06-11-2014
    Posts
    20

    Re: Folder Picker - picking files in chronological order

    No problem. Thanks for the help!

  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: Folder Picker - picking files in chronological order

    You're welcome!

+ 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. VBA to list only new files in folder or in order
    By acowan2307 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-25-2021, 12:22 AM
  2. [SOLVED] Rows automatically in chronological order
    By Nico Zottos in forum Excel General
    Replies: 2
    Last Post: 12-12-2014, 12:18 AM
  3. [SOLVED] Loop thru files in chronological order
    By cokillerliu in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2013, 10:02 AM
  4. obtain chronological order without sorting
    By Diamant in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-21-2012, 12:18 AM
  5. [SOLVED] Re-Arranging Numbers to be in Chronological Order
    By rlpowers in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2012, 10:21 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