Option Explicit
Sub Consolidation()
Dim i As Long, j As Integer, n As Long, k As Integer, m As Integer, total As Integer
Application.ScreenUpdating = False
Sheets("Calculs").[A1].CurrentRegion.ClearContents
Call Ouverture_Classeur
Sheets("Calculs").Activate
Application.Calculation = xlCalculationManual
m = 0
For j = 1 To 8
For i = 1 To 250
n = 251
n = n + m
total = Cells(i, j) + Cells(n, j)
For k = 1 To Application.CountA(Sheets("Matrice").Range("A:A")) - 1
n = n + 250
total = total + Cells(n, j)
Next k
Sheets("Résultat").Cells(i, j) = total
m = m + 1
Next i
m = 0
Next j
'Application.FileDialog(msoFileDialogFolderPicker).Show ' Ouverture boite de dialogue
Application.Calculation = xlCalculationAutomatic
Sheets("Résultat").Activate
Application.ScreenUpdating = True
End Sub
Sub Ouverture_Classeur()
Dim fichier As String, i As Byte, Flag As Boolean
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
fichier = Cells(i, 1)
On Error Resume Next
Workbooks(fichier).Activate
If Err.Number <> 0 Then
Workbooks.Open fichier
End If
If Flag = False Then
[A1].CurrentRegion.Copy Destination:=ThisWorkbook.Sheets("Calculs").Range("A" & Rows.Count).End(xlUp)
Else
[A1].CurrentRegion.Copy Destination:=ThisWorkbook.Sheets("Calculs").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
End If
Flag = True
ActiveWorkbook.Close
Next i
End Sub