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

CodeFunctionName
What is this?

Public

Tested

Original Work
' 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 3,180

Downloads 1,265

CodeID
DB ID

ANmarAmdeen
602
Revisions

v1.0

Sunday
June
10
2018
Needs