I have a piece of code that opens up .csv files within a master folder.... But, I found out that they will each be in separate subfolders (inside master folder). So I need to adjust this code to help me go about searching through the subfolders:
Sub loopthroughfiles()
Dim mainwb As Workbook
Dim WB As Workbook
Dim i As Integer
'set a variable as the active open work book that the macro is running from, clear contents
Set mainwb = ActiveWorkbook
'set file path
Set FileSYstemObj = CreateObject("Scripting.FileSystemObject")
Set FolderObj = FileSYstemObj.GetFolder("C:\Users\E1TCH02\Desktop\Input")
For Each fileobj In FolderObj.Files 'loop through the files
If FileSYstemObj.GetExtensionName(fileobj.Path) = "csv" Then
Application.DisplayAlerts = False
Set WB = Workbooks.Open(fileobj.Path)
'I do a bunch of copying, adjusting, and pasting between the opened file and the mainwb
End If
Next fileobj
mainwb.Activate
mainwb.Save
End Sub
Can anyone guide me in the right direciton? Any help would be appreciated greatly.
Bookmarks