Private Sub GetFiles()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim pFol As String, xcode As String
Dim fso As Object, fol As Object, subFol As Object, fil As Object
Dim filPath As String
Dim wb As Workbook
Dim i As Integer
With ThisWorkbook.Sheets(1)
.Range("B5:E5").Value = Empty 'change this to reset sum range
pFol = "D:\OT Management"
xcode = Format(.Range("B2").Value, "00") & .Range("C2").Value
Set fso = CreateObject("Scripting.FileSystemObject")
Set fol = fso.GetFolder(pFol)
For Each subFol In fol.SubFolders
If subFol.Name = xcode Then
For Each fil In subFol.Files
filPath = fso.GetAbsolutePathName(fil)
If filPath Like "*.xlsx" Then
Set wb = Workbooks.Open(filPath, 0) 'open with not update link
For i = 0 To 3
.Range("B5").Offset(, i).Value = .Range("B5").Offset(, i).Value + wb.Sheets("Summary").Range("C6").Offset(, i).Value 'change this to sum C6~F6
If wb.Name Like "90## SMod.xlsx" Then
.Range("B6").Offset(, i).Value = wb.Sheets("Summary").Range("C12").Offset(, i).Value
End If
Next i
wb.Close (False)
End If
Next fil
End If
Next subFol
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub