LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Opening Files from a folder in sorted order.

From the command prompt:

dir c:\yourfolder /ON /b c:\myfile.lst

will write the names of all files in alphabetical order (case insensitiveie.
a and A before b and B etc).

You can then read c:\myfile.lst line by line and open each one in turn

"Excel Beginner" wrote:

Hi All,

Please find the following bit of code in my program:

'-------------------------------------------------------------------------
varWorkbookName = Application.GetOpenFilename("Microsoft Excel
files (*.xls),*.xls", , "Please select the file(s) to process", ,
True)
If TypeName(varWorkbookName) = "Boolean" Then Exit Sub

For lngNoOfPayrolls = 1 To UBound(varWorkbookName)
strCurrentWorkbook = Dir(varWorkbookName(lngNoOfPayrolls))

Workbooks.Open varWorkbookName(lngNoOfPayrolls)
'-------------------------------------------------------------------------

The files in the folder are like:
Dec99 BOT
Nov99 BOT
Dec99 HKG
Nov99 HKG
..
..
so on for all the months and years from Jan99 till Mar05. The files
are in random order in this folder.

I basically want to open them in sorted order (Atleast sorted
according to the first 5 characters of the filename) , i.e.,
Apr99 BOT
Apr99 HKG
..
..
so on

I hope I have been clearer in explaining the situation. I would
appreciate if someone come back to me asap.

Thanks

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
order of opening files with sumproduct returning #REF! sharon p Excel Worksheet Functions 2 September 15th 09 05:29 PM
Default folder for opening/saving files Dino Excel Discussion (Misc queries) 2 July 5th 07 11:28 PM
Opening files from a variable (todays' date) folder name Hari[_3_] Excel Programming 2 June 10th 04 04:03 PM
opening and closing files in order with vba shane[_2_] Excel Programming 1 April 13th 04 12:00 AM
Opening all txt files in a folder and saving as excel Jason Excel Programming 1 February 23rd 04 09:01 PM


All times are GMT +1. The time now is 05:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"