I have the below code that results in a loop error because the code does not ignore the source file.
Can someone adjust?
Hope I provided enough ...
Can someone adjust?
Hope I provided enough ...
VBA Code:
Dim fso As FileSystemObject
Dim f As Folder, sf As Folder
Dim ofile As File
Dim lr As Long, LRM As Long
Dim MyPath As String, MyFile As String, File As Workbook
Dim sFolder As String
Dim sFile As String
Dim wbSource As Workbook
Dim wbMaster As Workbook
Dim shTarget As Worksheet
Dim shSource As Worksheet
Application.ScreenUpdating = False
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(ThisWorkbook.Path & "\")
'================================================
' Loop through all files within the same folder
'================================================
For Each f In f
If Not f.Name = "Archive" Or Not f.Name = "ReportWriter.xlsm" Then
For Each ofile In f.Files
If Left(fso.GetExtensionName(ofile.Path), 4) = "xlsm" Then
Set wbMaster = ThisWorkbook
If ofile.Name <> ThisWorkbook.Name Then
Set wbSource = Workbooks.Open(ofile)