1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Sub ListFilesInFolder(strFolderName As String, bIncludeSubfolders As Boolean)
RunTime
Static FSO As FileSystemObject
Dim oSourceFolder As Scripting.Folder
Dim oSubFolder As Scripting.Folder
Dim oFile As Scripting.File
Dim wksDest As Worksheet
Dim Classeur As Workbook
Dim DD As Integer
Set wksDest = ActiveSheet
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oSourceFolder = FSO.GetFolder(strFolderName)
i = 1
For Each oFile In oSourceFolder.Files
Application.ScreenUpdating = False
Workbooks.Open oFile, True
wksDest.Range(cell1, i) = Sheets(2).Name
wksDest.Range(cell2, i) = "=SUM('" & Sheets(2).Name & "'!AF:AF)"
Workbooks.Close
i = i + 1
Next oFile
Application.ScreenUpdating = True
End Sub |
Partager