I am struggling with a problem using an array of folders and looping through them to perform an activity. I do not want to get in to any of the sub-folders. When i run the following I get in to some looping issues that I cannot figure out how to resolve. Any assistance is much appreciated. I have commented out certain things i thought could be the cause, but to not avail.
Code:
Sub newtest()
Dim fso As Object
Dim objFolder As Object
'Dim objSubFolder As Object
Dim FromPath As String
Dim FileInFolder As Object
Dim i As Integer
FoldersName = Array("Budget Benoit", "Budget Logsdon", "Budget NRL", "Budget Rumfield") '"Budget Trisvan"
FromPath = "F:\Finance\2018\2018 Budget\Budget-OTP\"
Set fso = CreateObject("Scripting.filesystemobject")
For i = 1 To UBound(FoldersName)
Set objFolder = fso.GetFolder(FromPath & FoldersName(i) & "\")
rowOffset = 1
Do While objFolder <> ""
For Each FileInFolder In objFolder.Files
'fileName = Dir(folderPath & "*.xlsx")
'Do While FileInFolder <> ""
'Copy data from dated workbook to associated row in summary sheet
Workbooks.Open FileInFolder
Sheets("Budget Summary").Range("A12:E12").Copy
thisWorkbook.Sheets("Sheet1").Range("B1").Offset(rowOffset, 0).PasteSpecial Paste:=xlPasteValues
'Enter file name in column A
thisWorkbook.Sheets("Sheet1").Range("a1").Offset(rowOffset, 0) = FileInFolder
'Increment to next row
rowOffset = rowOffset + 1
'Clear the clipboard then close the file with no changes
Application.CutCopyMode = False
ActiveWorkbook.Close savechanges:=False
'Get next file name
'FileInFolder = Dir
'Loop
Next FileInFolder
'Next objFolder
Loop
Next
'Clean up housekeeping
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
'Determine how many seconds code took to run
MinutesElapsed = Format((Timer - StartTime) / 86400, "hh:mm:ss")
'Notify user in seconds
MsgBox "This code ran successfully in " & MinutesElapsed & " minutes", vbInformation
End Sub