Re,
Si j'ai bien compris la manière de fonctionner....
Code à essayer :
Sub Testdan()
'Macro Dan pour sophietaureau
Dim nbl As Integer, m As Integer, n As Integer, i As Integer, j As Integer
Dim v As Byte, w As Byte, c As Byte, a As Byte
Dim ga As String, dra As String, gb As String, drb As String
v = Application.Match("N°vol", Sheets("Sheet1").Range("A1:Z1"), 0)
w = Application.Match("Ligne", Sheets("Sheet1").Range("A1:Z1"), 0)
c = Application.Match("Capacité", Sheets("Sheet1").Range("A1:Z1"), 0)
a = Application.Match("Avion", Sheets("Sheet1").Range("A1:Z1"), 0)
nbl = Range("A20000").End(xlUp).Row
For i = nbl To 3 Step -1
ga = Mid(Cells(i - 1, w), 1, 3)
dra = Mid(Cells(i - 1, w), 5, 7)
gb = Mid(Cells(i, w), 1, 3)
drb = Mid(Cells(i, w), 5, 7)
m = Mid(Cells(i - 1, v), 4, 7)
n = Mid(Cells(i, v), 4, 7)
Select Case n - m
Case Is = 1
If ga = drb And gb = dra Then
If Cells(i, a) = Cells(i - 1, a) Then
Rows(i).Delete Shift:=xlUp
i = i - 1
End If
End If
Case Is > 1
For j = i - 1 To 6 Step -1
If Cells(i, a) = Cells(j, a) Then
Rows(i).Delete Shift:=xlUp
Exit For
Next
End Select
Next i
End Sub
J'ai enlevé la variable p qui ne sert pas dans le code
Amicalement