Ajout code VB

Doustik Messages postés 43 Statut Membre -  
Doustik Messages postés 43 Statut Membre -
Bonjour,

J'ai programmé mon userform pour pouvoir enregistrer de nouveau produit mais ce qui ne fonctionne pas c'est le contrôle.
si quelqu'un pouvais y jeter un coup d'oeil et me dire ce qui ne va pas ça m'aiderai
merci

http://www.cijoint.fr/cjlink.php?file=cj201006/cijRJQhyqD.zip

1 réponse

  1. Doustik Messages postés 43 Statut Membre
     
    Private Sub Ajouter_Click()
    ' Permet de selctionner la dernière ligne d'un tableau
    ' Soit A1, la cellule considérée.
    ' Range("A1").End(xlDown).Row + 1
    Worksheets("Services").Cells(Range("Services!A2").End(xlDown).Row + 1, 1) = TextBox9.Value
    Worksheets("Services").Cells(Range("Services!E2").End(xlDown).Row + 1, 2) = TextBox6.Value
    Worksheets("Services").Cells(Range("Services!G2").End(xlDown).Row + 1, 3) = TexBox7.Value
    Worksheets("Services").Cells(Range("Services!H2").End(xlDown).Row + 1, 4) = TexBox8.Value
    Worksheets("Services").Cells(Range("Services!I2").End(xlDown).Row + 1, 5) = TexBox10.Value
    MsgBox "Votre produit a bien été ajouté"
    'Permet le tri automatique!
    Sheets("Services").[A1].Sort key1:=Sheets("Services").[A2], Order1:=xlAscending, Header:=xlGuess
    Ajout.Hide
    Unload Ajout
    End Sub
    Private Sub Annuler_Click()
    Ajout.Hide
    End Sub
    Private Sub CommandButton1_Click()
    Worksheets("Textile").Cells(Range("Textile!A2").End(xlDown).Row + 1, 1) = TextBox14.Value
    Worksheets("Textile").Cells(Range("Textile!E2").End(xlDown).Row + 1, 2) = TextBox11.Value
    Worksheets("Textile").Cells(Range("Textile!G2").End(xlDown).Row + 1, 3) = TextBox12.Value
    Worksheets("Textile").Cells(Range("Textile!H2").End(xlDown).Row + 1, 4) = TextBox13.Value
    Worksheets("Textile").Cells(Range("Textile!I2").End(xlDown).Row + 1, 5) = TextBox15.Value
    MsgBox "Votre produit a bien été ajouté"
    Sheets("Textile").[A1].Sort key1:=Sheets("Textile").[A2], Order1:=xlAscending, Header:=xlGuess
    Ajout.Hide
    Unload Ajout
    End Sub
    Private Sub CommandButton2_Click()
    Worksheets("Consommables bureau").Cells(Range("Consommables bureau!A2").End(xlDown).Row + 1, 1) = TextBox19.Value
    Worksheets("Consommables bureau").Cells(Range("Consommables bureau!E2").End(xlDown).Row + 1, 2) = TextBox16.Value
    Worksheets("Consommables bureau").Cells(Range("Consommables bureau!G2").End(xlDown).Row + 1, 3) = TextBox17.Value
    Worksheets("Consommables bureau").Cells(Range("Consommables bureau!H2").End(xlDown).Row + 1, 4) = TextBox18.Value
    Worksheets("Consommables bureau").Cells(Range("Consommables bureau!I2").End(xlDown).Row + 1, 5) = TextBox20.Value
    MsgBox "Votre produit a bien été ajouté"
    Sheets("Consommables bureau").[A1].Sort key1:=Sheets("Consommables bureau").[A2], Order1:=xlAscending, Header:=xlGuess
    Ajout.Hide
    Unload Ajout
    End Sub
    Private Sub CommandButton3_Click()
    Worksheets("Consommables terrain").Cells(Range("Consommables terrain!A2").End(xlDown).Row + 1, 1) = TextBox24.Value
    Worksheets("Consommables terrain").Cells(Range("Consommables terrain!E2").End(xlDown).Row + 1, 2) = TextBox21.Value
    Worksheets("Consommables terrain").Cells(Range("Consommables terrain!G2").End(xlDown).Row + 1, 3) = TextBox22.Value
    Worksheets("Consommables terrain").Cells(Range("Consommables terrain!H2").End(xlDown).Row + 1, 4) = TextBox23.Value
    Worksheets("Consommables terrain").Cells(Range("Consommables terrain!I2").End(xlDown).Row + 1, 5) = TextBox25.Value
    MsgBox "Votre produit a bien été ajouté"
    Sheets("Consommables terrain").[A1].Sort key1:=Sheets("Consommables bureau").[A2], Order1:=xlAscending, Header:=xlGuess
    Ajout.Hide
    Unload Ajout
    End Sub

    Private Sub CommandButton4_Click()
    Worksheets("Autres").Cells(Range("Autres!A2").End(xlDown).Row + 1, 1) = TextBox4.Value
    Worksheets("Autres").Cells(Range("Autres!E2").End(xlDown).Row + 1, 2) = TextBox1.Value
    Worksheets("Autres").Cells(Range("Autres!G2").End(xlDown).Row + 1, 3) = TextBox8.Value
    Worksheets("Autres").Cells(Range("Autres!H2").End(xlDown).Row + 1, 4) = TextBox3.Value
    Worksheets("Autres").Cells(Range("Autres!I2").End(xlDown).Row + 1, 5) = TextBox5.Value
    MsgBox "Votre produit a bien été ajouté"
    Sheets("Autres").[A1].Sort key1:=Sheets("Consommables bureau").[A2], Order1:=xlAscending, Header:=xlGuess
    Ajout.Hide
    Unload Ajout
    End Sub
    Private Sub UserForm_Click()

    End Sub

    J'ai modifié le code pck je me suis trompé dans les affectations des textbox mais ça ne fonctionne toujours pas
    0