Bonjour
Ci joint une proposition de macro simple à lancer avec Ctrl+Maj+T qui a l'air de fonctionner dans ton fichier
Sub Macro1()
'
' Macro1 Macro
'
Sheets("Data_With_period").Select ' vider existant
Rows("2:65000").Select
Selection.Clear
Sheets("Données").Select ' taille de la zone
Range("a1").Select
Selection.CurrentRegion.Select
Selection.End(xlDown).Select
vligf = ActiveCell.Row
Range("a1").Select
Selection.CurrentRegion.Select
Selection.End(xlToRight).Select
vcolf = ActiveCell.Column
Range(Cells(1, 1), Cells(vligf, vcolf)).Select ' tri de la colonne D pour isoler Null
ActiveWorkbook.Worksheets("Données").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Données").Sort.SortFields.Add Key:=Range(Cells(2, 4), Cells(vligf, 4)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Données").Sort
.SetRange Range(Cells(1, 1), Cells(vligf, vcolf))
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("D:D").Select ' recherche du premier null
Selection.Find(What:="NULL", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
vlig = ActiveCell.Row - 1 ' dernière ligne à copier
Range(Cells(2, 1), Cells(vlig, 9)).Select
Selection.Copy
Sheets("Data_With_period").Select
Rows("2:2").Select
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
End Sub
Il y aura surement quelqu'un qui fera plus court...
Ne pas changer le nom des onglets...
Transmis à toutes fins utiles
Cordialement
FINDRH