Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Find a file position and continue to list following files

Hi,
I can list all of the files in a folder. However I need to point a specific
file in the folder and list following 50 files by every click a command
button.

# of files in the folder more than 10.000. I have taken all the file names
to an array and sorted the array. But It takes too long time because folder
is dynamic (new files are added and deleted) and I must update the array each
time.

Could you help me to find more efficient way to do it?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Find a file position and continue to list following files

I don't know if this is faster but it's a different approach that might be
worth testing. It's a modification of a script I've used and I suspect it
may be more efficient to put the data on a sheet to sort when you're in
Excel but that may not be the case. Modify the line that sets the myPath
variable and give this a shot.

'--------------------------------------------

Sub AlphabetizeFileSet()

Const adVarChar = 200
Const MaxCharacters = 255

Dim myPath As String
Dim Fcnt As Integer

myPath = "C:\Scripts"

Set fso = CreateObject("Scripting.FileSystemObject")

Set targetFldr = fso.GetFolder(myPath)
Fcnt = targetFldr.Files.Count

Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "FileName", adVarChar, MaxCharacters
DataList.Open

For Each myFile In targetFldr.Files
DataList.AddNew
DataList("FileName") = fso.GetFileName(myFile)
DataList.Update
Next myFile

DataList.Sort = "FileName"

' Do some stuff with sorted list of file names
DataList.AbsolutePosition = 1
MsgBox DataList.Fields.Item("FileName")
DataList.MoveNext
MsgBox DataList.Fields.Item("FileName")
DataList.AbsolutePosition = Fcnt
MsgBox DataList.Fields.Item("FileName")

Set fso = Nothing
Set DataList = Nothing

End Sub


'--------------------------------------------

Steve Yandl



"KT1972" wrote in message
...
Hi,
I can list all of the files in a folder. However I need to point a
specific
file in the folder and list following 50 files by every click a command
button.

# of files in the folder more than 10.000. I have taken all the file names
to an array and sorted the array. But It takes too long time because
folder
is dynamic (new files are added and deleted) and I must update the array
each
time.

Could you help me to find more efficient way to do it?

Thanks.



Reply
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
Find a file position and continue to list following files joel Excel Programming 0 April 25th 09 02:10 PM
find files from a dropdown list [email protected] Excel Programming 1 February 14th 09 04:14 PM
How do you find the position of the first value (< 0) in a list Mike@Gentech Excel Discussion (Misc queries) 2 August 1st 08 01:20 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM
Find a value if there continue Tempy Excel Programming 2 May 19th 04 08:53 PM


All times are GMT +1. The time now is 10:47 PM.

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

About Us

"It's about Microsoft Excel"