Hello Steelson
Oui effectivement c'est bien ton code !
J'ai un problème lorsque je lance lance macro :
" Run-time Error '91':
Object variable or With Block Variable not Set"
A la ligne :
Set jusque = depuis.End(xlToRight).End(xlDown)
Le code complet :
Sub collecter()
Dim wbk1 As Workbook, wbk2 As Workbook, ws1 As Worksheet
Dim MonRepertoire, Repertoire As FileDialog, monFichier$, derL%, derL1%
Set Repertoire = Application.FileDialog(msoFileDialogFolderPicker)
Application.FileDialog(msoFileDialogFolderPicker).Title = "Choix du répertoire de stockage des fichiers générés"
Repertoire.Show
If Repertoire.SelectedItems.Count = 0 Then Exit Sub
MonRepertoire = Repertoire.SelectedItems(1) & "\"
Set wbk1 = ThisWorkbook
Set ws1 = wbk1.ActiveSheet
Cells(Rows.Count, 1).End(xlUp).CurrentRegion.Offset(1, 0).ClearContents
monFichier = Dir(MonRepertoire & "*.xlsx")
Do While monFichier <> ""
ws1.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Select
derL = ws1.Cells(Rows.Count, 3).End(xlUp).Row + 1
Set wbk2 = Workbooks.Open(MonRepertoire & monFichier)
Set depuis = wbk2.ActiveSheet.Rows("1:1").Find(What:="Status Cocode", After:=wbk2.ActiveSheet.Range("A1"), LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set jusque = depuis.End(xlToRight).End(xlDown)
Range(depuis, jusque).Copy
ws1.Paste
ws1.Range("B" & derL & ":B" & ws1.Cells(Rows.Count, 3).End(xlUp).Row) = wbk2.Name
Application.DisplayAlerts = False
wbk2.Close False
Application.DisplayAlerts = True
Rows(derL).Delete Shift:=xlUp
monFichier = Dir
Loop
End Sub