![]() |
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. |
All times are GMT +1. The time now is 10:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com