Bonjour,
Voila j'ai une macro qui fonctionne le seul problème c'est je suis obliger de la mettre dans un répertoire.
en fait je voudrais pouvoir l'exécuter en spécifiant le chemin et le répertoire sur laquelle elle effectue le traitement, pour info je suis novice.
Si quelqu'un peut m'aider je lui en serai très reconnaissant car cela fais un temps fou que j'y passe sans trouvé de solution.
Merci d'avance pour votre aide.
Si dessous le code en question :
Public Sub Consolidation_donnees()
Dim Wb As Workbook
Dim Table As ListObject
Dim strPath As String, strFilename As String
Dim rCell As Range
Dim lastRow As Long
Const LROW As Byte = 21
Application.ScreenUpdating = False
Set Table = ActiveSheet.ListObjects(1)
With Table
If Not .DataBodyRange Is Nothing Then .DataBodyRange.Delete
Set rCell = .InsertRowRange.Cells(1)
End With
strPath = ThisWorkbook.Path & Application.PathSeparator
strFilename = Dir(strPath & "*.xls*")
While strFilename <> ""
If strFilename <> ThisWorkbook.Name Then
Set Wb = Workbooks.Open(strPath & strFilename)
With Wb.Worksheets("SuiviPlanning")
lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row - 1
.Cells(LROW, 1).Resize(lastRow - LROW + 1, 8).Copy
rCell.PasteSpecial xlPasteValues
Application.CutCopyMode = 0
Set rCell = Table.HeaderRowRange.Cells(1).Offset(Table.ListRows.Count + 1)
End With
Application.EnableEvents = False
Wb.Close savechanges:=False
Set Wb = Nothing
End If
strFilename = Dir
Wend
Set rCell = Nothing: Set Table = Nothing
Cordialement,
Spindral