MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old Mar 30th, 2004, 08:38 PM   #1
bougler
 
Join Date: Mar 2004
Posts: 7
Default sort filenames in FoundFiles

Hi,

I am new at VBA and I have this problem. I want to load a bunch of files by filename (e_us1.dat to e_us11.dat). I am using the code below but the filenames come in the wrong order: e_us1, e_us10, e_us11, e_us2, e_us3...e_us9. Any ideas on how to sort them ? Thanks.

With Application.FileSearch
.LookIn = "C:\"
.Filename = "e_us*"
If .Execute(SortBy:=msoSortByFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There are " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
Exit Sub
End If
End With

Benedicte
bougler is offline   Reply With Quote
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 07:04 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.