This is something that most of us would want to do more often than once in a while. Be able to loop through the files in a folder, and also use some sort of filter.
Code:
Sub EFLoopThroughFilesInAFolder()
Dim strFile As String
Dim strFileType As String
Dim strPath As String
Dim lngLoop As Long
strPath = "C:\Journals"
strFileType = "*.csv" 'Split with semi-colon if you want to specify the file types. Example ->> "*.xls;*.jpeg;*.doc;*.gif"
For lngLoop = LBound(Split(strFileType, ";")) To UBound(Split(strFileType, ";"))
strFile = Dir(strPath & "\" & Split(strFileType, ";")(lngLoop))
Do While strFile <> ""
'This is where you need to write what you need
'The entire path of the file would be : strPath & "\" & strFile
strFile = Dir
Loop
Next lngLoop
strFile = vbNullString
strFileType = vbNullString
strPath = vbNullString
lngLoop = Empty
End Sub
Bookmarks