1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Dim LastLig As Long, i As Long
Dim LastCol As Integer, j As Integer
Application.ScreenUpdating = False
'adapter les noms des feuilles, Data et resultat à ton classeur
'le but est de copier chaque référence de flux comportant renvoi usine client
With Sheets("Data")
If AutoFilterMode Then .Range("A1").AutoFilter
LastLig = .Range("A1").End(xlDown).Row
LastCol = .Range("A1").End(xlToRight).Column
.Cells(2, LastCol + 1).Formula = "=if(mod(sumif(" & .Range("A2:A" & LastLig).Address & "," & .Range("A2").Address(0, 0) & "," & .Range("B2:B" & LastLig).Address & "),2)=0,0,1)"
.Cells(2, LastCol + 1).AutoFill .Range(.Cells(2, LastCol + 1), .Cells(LastLig, LastCol + 1))
.Range("A1").AutoFilter field:=LastCol + 1, Criteria1:="1"
.Range(.Cells(1, 1), .Cells(LastLig, LastCol)).SpecialCells(xlCellTypeVisible).Copy Sheets("Resultat").Range("A1")
.Range("A1").AutoFilter
.Columns(LastCol + 1).ClearContents
End With |
Partager