+ Reply to Thread
Results 1 to 3 of 3

Open workbooks within a directory in numerical order, like windows name sorting does

  1. #1
    Registered User
    Join Date
    01-04-2014
    Location
    Wisconsin, USA
    MS-Off Ver
    Excel 2010
    Posts
    55

    Open workbooks within a directory in numerical order, like windows name sorting does

    I am able to open all files in a directory easily but the problem is excel opens them in alpha numeric order.

    Excel opens them like this..........

    xyz1152.xlsx
    xyz1248.xlsx
    xyz567.xlsx
    xyz672.xlsx
    xyz768.xlsx
    xyz877.xlsx
    xyz9.xlsx
    xyz96.xlsx
    xyz988.xlsx

    I need them opened in increasing order.
    xyz9
    xyz96
    xyz567
    xyz672
    xyz768
    xyz877
    xyz988
    xyz1152
    xyz1248

    I plan to pull a row of data off each file and place that row in order downward on a master sheet.
    a b c d e f - from 96
    a b c d e f - from 567
    a b c d e f - from 672
    etc etc




    This is what I have so far with help from other searching...

    Problem is the CreateFileList is not in the numerical order that I need.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,620

    Re: Open workbooks within a directory in numerical order, like windows name sorting does

    Hi,
    If the part "xyz" is constant it shall be easy task.
    instead of:
    Please Login or Register  to view this content.
    write in wsList.Range("A" & Rows.Count).End(xlUp).Offset(1, 0) only numerical part of fName.
    For instance
    Please Login or Register  to view this content.
    4 because we drop first 3 letters and start from 4th (which is already a digit)
    7 because besides first 3 letters, we do not want also last 4 characters ".xls"

    Please Login or Register  to view this content.
    shall be moved after sorting, and between sorting and AutoFit removed parts of filename shall be restored.
    for instance
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open workbooks within a directory in numerical order, like windows name sorting does

    Why not import them in whatever order, grab the data and file name and then sort the data on the filename?
    If posting code please use code tags, see here.

+ 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. sorting a column in numerical order
    By affj in forum Excel General
    Replies: 2
    Last Post: 07-19-2013, 11:13 AM
  2. Macro to open Windows directory
    By robphillips79 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-10-2008, 10:10 AM
  3. Open workbook in the same directory using workbooks.open
    By saugui in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2006, 02:18 AM
  4. Replies: 2
    Last Post: 06-12-2006, 10:20 PM
  5. [SOLVED] Listing Order of Open Windows in Excel 2003
    By ARW in forum Excel General
    Replies: 1
    Last Post: 01-03-2006, 02:10 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