Bonsoir,
J'ai bien réussi à faire mes consolidations quand le nom du chemin est dans une cellule fixe (.Range("C5).Value), mais je n'arrive pas a rendre cela dynamique (.Feuil11.Cells(i,10).Value) le chemin utilisé doit dépendre de cette donnée.
<Sub dupliquer_data()
Dim wbks As Workbook, wbkc As Workbook, x As Variant
Dim ws As Worksheet
Dim Cheminfichier As String
Dim f As Object, Fso As Object, adr$
Set Fso = CreateObject("Scripting.FileSystemObject")
Set wbkc = ThisWorkbook
Application.ScreenUpdating = False
Dim ModeCalcul
With Application
ModeCalcul = Application.Calculation
.Calculation = xlCalculationManual
.EnableEvents = False
.ScreenUpdating = False
End With
Dim nom
For i = 4 To 14
If Feuil11.Cells(i, 8) = 1 Then
nom = Feuil11.Cells(i, 6).Value
Application.DisplayAlerts = False
Feuil4.Copy , After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = nom
ActiveSheet.Range("A1").Value = Feuil4.Cells(i, 1)
'For Each f In Fso.GetFolder(Sheets("Consolidate").Range("C5").Value).Files
For Each f In Fso.GetFolder(Sheets("Consolidate V3").Feuil11.Cells(i, 10).Value).Files
If Not f = ThisWorkbook.FullName And Not f Like "*~$*" Then
Set wbks = Workbooks.Open(f)
For Each ws In wbks.Worksheets
With ws
.Range("B15:P15" & .Range("C10000").End(xlUp).Row).Copy wbkc.Sheets(3).Range("C100000").End(xlUp).Offset(1, 0)
End With
Next
wbks.Close 0
End If
Next f
Application.ScreenUpdating = True
MsgBox "Consolidation Terminée", , "Traitement Terminé"
End If
Next i
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub>