Consulting

Results 1 to 2 of 2

Thread: Loop through files in order of date created

  1. #1

    Loop through files in order of date created

    Hi all,

    first off thanks for any help.

    im using the below code to loop through files but it automatically loops through the files alphabetically, is it possible to modify such that the loop is sorted by Date modified (earliest first)?

    thanks

    MyFile = Dir(MyPath)Do While MyFile <> ""
     'do stuffs
        MyFile = Dir
    Loop

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    sub M_snb()
       sn=split(createobject("wscript.shell").exec("cmd /c Dir G:\OF*.* /b/o-d").stdout.readall,vbcrlf)
    
       for j=0 to ubound(sn)-1
         msgbox sn(j)
       next
    end sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •