+ Reply to Thread
Results 1 to 4 of 4

Open Text File in order which is look like in folder

  1. #1
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Open Text File in order which is look like in folder

    Hello Friends,

    i have a multiple text files in a folder and i am opening it one by one.
    Filename of each text file like "04082016_92.txt", "04082016_93.txt", "04082016_94.txt", "04082016_100.txt"

    filenumber is not in same digit so macro try to open "04082016_100.txt" file first.
    i want to open each text file in order as it shows in folder.

    Please suggest

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,638

    Re: Open Text File in order which is look like in folder

    In principle, I think you need to:
    1. loop through the files in the folder
    2. Store the file names in a temporary worksheet
    3. Use Text to columns to separate out the nnn.txt part of the file name (into a new column)
    4. Use Replace All to remove the .txt part of the cell to leave only the numeric part.
    5. Sort on the number column to get them in the correct order
    6. Loop through the sorted stored file names
    7. Open and process each file

    Sorry, I don't have time to do this but you already have a loop and you should be able to get most of the rest by recording macros.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Open Text File in order which is look like in folder

    thanks for quick reply.
    i will manage as you suggest

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,638

    Re: Open Text File in order which is look like in folder

    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. [SOLVED] Open word file from userform with folder and file names as per textbox values
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-14-2015, 03:57 PM
  2. [SOLVED] Lookup folder from cell text, then save excel file in this folder
    By dodgybob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2014, 09:00 AM
  3. [SOLVED] Open specific folder, select file to open and copy then paste
    By Kranky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2012, 12:14 AM
  4. [SOLVED] Open all files in a SharePoint folder (Problem: Files open out of order)
    By holmstarrunner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-10-2012, 10:13 AM
  5. How to get the open file dialog to open to a certain folder
    By tenk283 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-01-2010, 11:54 PM
  6. File Open Dialog Box Open at Set Folder
    By Soltisolti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2007, 10:05 PM
  7. open file from folder save in new folder
    By tim64 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 06-17-2005, 03:19 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