XL 2016 Copie textBox UserForm dans plusieurs onglets

JLR67

XLDnaute Nouveau
Bonjour,
J'ai créé un UserForm avec TextBox et ComboBox. L'idée c'est qu'il me copie les données dans l'onglet "Atelier" et en partie sur un de onglets "Compte .." selon ce qui est noté dans la ComboBox2. Autant les données de l'Userform sont bien intégrées dans le tableau de l'onglet "Atelier" mais sont erronées sur les autres onglets.
N'étant pas assez calé dans le VBA, je m'adresse à vous pour m'aider à trouver l'erreur.
Je joint un fichier que j'ai créé spécialement, vu que le fichier d'origine est trop lourd.

Merci à ceux qui voudront bien prendre le temps de me répondre

Jean Louis
 

Pièces jointes

  • Test 3.xlsm
    36 KB · Affichages: 7

natorp

XLDnaute Accro
Bonsoir JLR67

Vous formatez le textbox1 ici :
VB:
Private Sub TextBox1_KeyPress(ByVal KeyAsCii As MSForms.ReturnInteger) 'Défini la façon d'écrire la date dans le textBox1
    Dim VT As Integer
    TextBox1.MaxLength = 10
    Select Case KeyAsCii
       Case 46, 48 To 57
 
            VT = Len(TextBox1)
            If VT = 2 Or VT = 5 Then TextBox1 = TextBox1 & "/"
        Case Else
            KeyAsCii = 0
            MsgBox "CARACTERE NON AUTORISE"
    End Select
End Sub

Il n'est plus nécessaire ici (===>):
Code:
Private Sub CommandButton2_Click()
    Num = -1
    Reponse = MsgBox("Confirmez-vous le versement d'un nouveau dividende ?", _
                     vbYesNo, "Demande de confirmation d'un nouveau dividende")
 
    If Reponse = vbYes Then
      
    L = Sheets("Atelier").Range("A1").End(xlDown).Row + 1
    Sheets("Atelier").Range("A" & L).Value = Num + L
    Sheets("Atelier").Range("B" & L) = CDate(TextBox1) '"DATE"
===>        'TextBox1.Value = Format(Val(Replace(TextBox1.Value, "-", "/")), "dd/mm/yyyy")
    Sheets("Atelier").Range("C" & L) = Val(ComboBox3)  '"CODE TACHE"
        ComboBox3.Value = Format(Val(Replace(ComboBox3.Value, ".", ",")), "#,##0")
    Sheets("Atelier").Range("D" & L).Value = ComboBox1  '"DESIGNATION TACHE"
    Sheets("Atelier").Range("E" & L) = Val(TextBox2)  '"MONTANT TACHE"
        TextBox2.Value = Format(Val(Replace(TextBox2.Value, ".", ",")), "#,##0.00 €")
    Sheets("Atelier").Range("F" & L).Value = ComboBox2  '"Opérateur"
        

     If ComboBox2 = "JL" Then
     Num = -1
 
   L1 = Sheets("Compte JL").Range("A1").End(xlDown).Row + 1
    Sheets("Compte JL").Range("A" & L1).Value = Num + L1
    Sheets("Compte JL").Range("B" & L1) = CDate(TextBox1) '"DATE"
===>        'TextBox1.Value = Format(Val(Replace(TextBox1.Value, "-", "/")), "dd/mm/yyyy")
    Sheets("Compte JL").Range("C" & L1).Value = ComboBox1  '"DESIGNATION TACHE"
    Sheets("Compte JL").Range("E" & L1) = Val(TextBox2)  '"MONTANT TACHE"
        TextBox2.Value = Format(Val(Replace(TextBox2.Value, ".", ",")), "#,##0.00 €")

Cordialement, Gérard
 

Discussions similaires

Statistiques des forums

Discussions
312 164
Messages
2 085 864
Membres
103 007
dernier inscrit
salma_hayek