Dim Feuille As Worksheet
Dim Ligne   As Long
Dim I       As Integer
Private Sub UserForm_Initialize()
    Set Feuille = ThisWorkbook.Sheets("Feuil1")
    
  ' Chargement des intitulés dans la combobox2
    Ligne = Feuille.Cells(Feuille.Rows.Count, "A").End(xlUp).Row
    ComboBox2.RowSource = vbNullString
    ComboBox2.List = Feuille.Range("A2:A" & Ligne).Value
    
End Sub
Private Sub ComboBox2_Change()
  ' On va provoquer un calcul si ajustement > 0
    TextBox23_Change
End Sub
Private Sub CommandButton1_Click()
    If ComboBox2.Value = vbNullString Then
        MsgBox "Veuillez renseigner le champs intitulé de la recette "
    Else
        Dim Ligne As Integer
        If MsgBox("confirmez-vous l'ajout des données?", vbYesNo, "confirmation") = vbYes Then
            Feuille.Activate
            Ligne = Feuille.Cells(Feuille.Rows.Count, "A").End(xlUp).Row + 1
            Feuille.Cells(Ligne, 1) = ComboBox2.Value
            For I = 1 To 22
                Feuille.Cells(Ligne, I + 1) = Me.Controls("TextBox" & I).Value
            Next
            Unload Me
        End If
    End If
End Sub
Private Sub CommandButton2_Click()
    Unload Me
End Sub
Private Sub Charger()
    If Not ComboBox2.Value = vbNullString Then
        ' On charge toutes les cellules de la ligne
        ' correspondante à l'intitulé
        ' dans les textboxs séquentiels
        Ligne = ComboBox2.ListIndex + 2
        For I = 1 To 22
            Me.Controls("TextBox" & I) = Feuille.Cells(Ligne, I + 1)
        Next
        TextBox21_Change
    End If
End Sub
Private Sub CommandButton3_Click()
    Charger
End Sub
Private Sub TextBox21_Change()
  ' La quantité de référence sera toujours égale à 1 au minimum
    If Val(TextBox21) < 1 Then TextBox21 = 1
End Sub
Private Sub TextBox23_Change()
    Charger
    If Val(TextBox23) > 0 Then
        For I = 11 To 20
            With Me.Controls("TextBox" & I)
                If Val(.Value) > 0 Then .Value = Application.WorksheetFunction.RoundUp(.Value * TextBox23 / TextBox21, 0)
            End With
        Next
    End If
End Sub