1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Sub test()
Dim c As Range, Tableau2 As Range
With Sheets("Feuil2")
Set Tableau2 = .Range(.[E4], .Cells(.Rows.Count, 6).End(xlUp))
For Each c In .Range(.[A4], .Cells(.Rows.Count, 1).End(xlUp))
If Not Application.IsNA(Application.VLookup(c.Value, Tableau2, 2, 0)) Then
If c.Offset(, 1) <> Application.VLookup(c.Value, Tableau2, 2, 0) Then
c.Offset(, 1) = c.Offset(, 1) - Application.VLookup(c.Value, Tableau2, 2, 0)
End If
If c.Offset(, 1) > 0 Then Exit Sub
End If
Next c
End With
End Sub |
Partager