Sub Stock()
Dim NbLig1 As Integer, NbLig2 As Integer, i As Integer, Adress As String
NbLig1 = ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
NbLig2 = Sheets("Feuil2").Cells.SpecialCells(xlCellTypeLastCell).Row
ActiveWorkbook.Worksheets("Feuil2").Range("A1").CurrentRegion.Name = "Stock"
For i = 1 To NbLig1 - 1
While Cells(i, 1).Value = Cells(i + 1, 1).Value
Cells(i + 1, 8).Formula = "=" & Cells(i, 8).Address & "-" & Cells(i + 1, 7).Address
i = i + 1
Wend
Cells(i + 1, 8).Formula = "=VLookup(Cells(i + 1, 1).Value&,Stock,3,False)"
Next i
End Sub
Partager