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

Do you need the files sorted. If so put the names on a worksheet and sort
worksheet. Then display from worksheet. Otherwise, just get 50 files at a
time using dir()

Method 1
Folder = "C:\temp\"
RowCount = 1
FName = dir(Folder & "*.*")
Do While FName < ""
Range("A" & RowCount) = FName
RowCount = RowCount + 1
FName = Dir()
loop

LastRow = RowCount - 1

Set SortRange = Range("A1:A" & LastRow)
SortRange.Sort _
key1:=Range("A1"), _
Order1:=xlascending, _
header:=xlno

-------------------------------------------------------------------
Method 2
Dim MyArray()
Redim MyArray(50)
Folder = "C:\temp\"
RowCount = 1
FName = dir(Folder & "*.*")
ItemCount = 1
Do While FName < ""
Range("A" & RowCount) = FName
MyArray(ItemCount) = FName
if ItemCount = 50 then
'display items
ItemCount = 1
else
ItemCount = ItemCount + 1
end if
RowCount = RowCount + 1
FName = Dir()
loop
If ItemCount < 1 then
'display items
end if


"KT1972" wrote:

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 files from a dropdown list [email protected] Excel Programming 1 February 14th 09 04:14 PM
find files from a dropdown list [email protected] Excel Worksheet Functions 2 February 14th 09 03:11 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 08:42 AM.

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"