Filesin_Coll + Filesin_Cells

Reads files in a specified folder into a Collection, work with VB6 and VBA also, accepts mask
or
Reads files in a specified folder into a range of cells, VBA-Excel only, accepts mask

' Reads the files in a specified folder into a Collection
' Needs FixPath()
' suitable with VB6 and VBA also
Sub Filesin_Coll(CoFiles as collection,FullPath, Optional FileS = "*.*", Optional Attr = 0)
'CoFiles.Clear
On Error GoTo ByeBye
di = Dir(FixPath(FullPath) & FileS, Attr)
Do Until di = ""
If di = "." Or di = ".." Then GoTo 300
CoFiles.Add di
300:
di = Dir
Loop
ByeBye:
On Error GoTo 0
End Sub

' Reads files in a specified folder into a range of cells
' Needs FixPath()
Sub Filesin_Cells(ToRange as range,FullPath, Optional FileS = "*.*", Optional Attr = 0)
i=0
On Error GoTo ByeBye
di = Dir(FixPath(FullPath) & FileS, Attr)
Do Until di = ""
If di = "." Or di = ".." Then GoTo 300
ToRange.Offset( I).Value = di
i=i+1
300:
di = Dir
Loop
ByeBye:
On Error GoTo 0
End Sub

CoFiles as collection,FullPath, Optional FileS = "*.*", Optional Attr = 0
or
ToRange as range,FullPath, Optional FileS = "*.*", Optional Attr = 0

Views 1826 Downloads 784


ANmarAmdeen
612
File System VBA-Excel
Revisions

v1.0

Needs