Sub majstock()
  Set f = Sheets("saisie")
  Set f2 = Sheets("BD")
  Set d = CreateObject("scripting.dictionary")
  Set Rng = f2.Range("A6:A" & f2.[A65000].End(xlUp).Row)
  For Each c In Rng
    If c.Value <> "" Then d(c.Value) = c.Offset(, 1)
  Next c
  If f.[A5] <> "" Then
    Set Rng2 = f.Range("A5:A" & f.[A65000].End(xlUp).Row)
    For Each c In Rng2
      If c.Value <> "" Then d(c.Value) = d(c.Value) - c.Offset(, 1)
    Next c
    f2.[A6].Resize(d.Count) = Application.Transpose(d.keys)
    f2.[B6].Resize(d.Count) = Application.Transpose(d.items)
    [D1] = Value
    '--- historique
    lig = f2.[F65000].End(xlUp).Row + 1
    f.[C1].Copy f2.Cells(lig, "E")
    f.[D1].Copy f2.Cells(lig, "H")
    Rng2.Resize(, 2).Copy f2.Cells(lig, "f")
   'ajout Verrue ==================================================
    For X = f2.[E65000].End(xlUp).Row To f2.[F65000].End(xlUp).Row
        f.[C1].Copy f2.Cells(X, "E")
    Next X
    'fin ajout verrue =============================================
    f.[A5:B1000].ClearContents
    f.[C1:D1].ClearContents
  End If
End Sub