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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| Sub maj()
Dim fso As New FileSystemObject
Dim fich As file
Dim Rep As Folder
Dim Wk As Variant
Dim TabFich() As String
Dim CL1 As Workbook, CL2 As Workbook
Dim FL1 As Worksheet, FL2 As Worksheet
Dim Premlig As Long, Derlig As Long
Set CL1 = ThisWorkbook
Set FL1 = CL1.Worksheets("Sommaire")
Set Rep = fso.GetFolder(Application.ThisWorkbook.Path & "\Thèmes")
FL1.Rows("74:65536").Delete
For Each fich In Rep.Files
Wk = Rep & "\" & fich.Name
If fso.GetExtensionName(Wk) = "xls" Then
CL1.Save
Premlig = FL1.Range("A65535").End(xlUp).Row + 1
Set CL2 = Workbooks.Open(Wk)
Set FL2 = CL2.Worksheets("sommaire")
FL2.Range("A15:" & FL2.Range("A1"). _
SpecialCells(xlCellTypeLastCell).Address).Copy _
Destination:=FL1.Range("B" & FL1.Range("B1"). _
SpecialCells(xlCellTypeLastCell).Row + 1)
Derlig = FL1.Range("A1").SpecialCells(xlCellTypeLastCell).Row
For i = Premlig To Derlig
FL1.Cells(i, 1).Value = Left(fich.Name, Len(fich.Name) - 4)
Next
CL2.Close
End If
Next
With FL1.Range("A74:" & "G" & FL1.Range("A1").SpecialCells(xlCellTypeLastCell).Row)
.VerticalAlignment = xlVAlignCenter
.HorizontalAlignment = xlHAlignCenter
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
.Borders(xlInsideHorizontal).LineStyle = xlContinuous
End With
'FL1.Calculate
Set Rep = Nothing
Set FL1 = Nothing
Set CL1 = Nothing
Set FL2 = Nothing
Set CL2 = Nothing
End Sub |