1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
Sub extrait()
Dim Ligne As Long
Dim Rep As String
Dim Strat As String
Dim NbLigne As Long
Dim NumLigne As Long
Dim testRep As String
Dim testStrat As Long
Sheets("feuil2").Activate ' feuille de destination
Strat = "m" ' colonne non vide à tester
Rep = "p" ' colonne données non vides à tester'
NumLigne = 2 'alors là ca doit etre le N° de la 1er ligne de données en comptant la ligne 1 = 0 .... ? '
With Sheets("inittial") ' feuille source'
NbLigne = .Cells(65536, Rep).End(xlUp).Row
'premiere valeur'
testRep = .Cells(2, Rep).Value
testStrat = .Cells(2, Strat).Value
For Ligne = 2 To NbLigne
MsgBox testStrat & "" & testRep
If .Cells(Ligne, Rep).Value = testRep Then
If .Cells(Ligne, Strat).Value >= testStrat Then
testRep = .Cells(Ligne + 1, Rep).Value
testStrat = .Cells(Ligne + 1, Strat).Value
Ligne = Ligne + 1
MsgBox "egal ou plus grand"
Else
testRep = .Cells(Ligne, Rep).Value
testStrat = .Cells(Ligne, Strat).Value
Ligne = Ligne + 1
MsgBox "imprimer....."
.Cells(Rep, Strat).EntireRow.copy
End If
Else
testRep = .Cells(Ligne, Rep).Value
testStrat = .Cells(Ligne, Strat).Value
End If
Next
End With
End Sub |
Partager