FilesIn + FilesIn_Count

Returns list of files found in a folder, list separated with custom separator
And FilesIn_Count to return number of files
Using Dir not FSO


Public

Tested

My Own Work
Function FilesIn(Optional FileMask = "*.*", Optional InFolder = "", Optional Attr = 0, Optional Sepa = "|")
Retu = ""
On Error GoTo ByeBye
di = Dir(FixPath(InFolder) & FileMask, Attr)
Do Until di = ""
If di = "." Or di = ".." Then GoTo 300
If Retu > "" Then Retu = Retu & Sepa
Retu = Retu & di
300:
di = Dir
Loop
ByeBye:
On Error GoTo 0
FilesIn = Retu
End Function

Function FilesIn_Count(Optional FileMask = "*.*", Optional InFolder = "", Optional Attr = 0, Optional Sepa = "|")
Retu = 0
On Error GoTo ByeBye
di = Dir(FixPath(InFolder) & FileMask, Attr)
Do Until di = ""
If di = "." Or di = ".." Then GoTo 300
Retu = Retu + 1
300:
di = Dir
Loop
ByeBye:
On Error GoTo 0
FilesIn_Count = Retu
End Function

FileMask, InFolder, Attr, Sepa

Views 2768 Downloads 1154

VBA-Excel File System
ANmarAmdeen
780
Revisions

v2.0

Tags
Needs