ecrire des donnees d'un userform dans un autre classeur

titoupoulpe

XLDnaute Nouveau
bonjour

je cherche à écrire les données de mon userform dans un autre classeur exel qui me sert de base de données :

le formulaire fonctionne ,mon second classeur s'ouvre mais aucune de mes donnes n'est écrite

voici le code que j'ai tapé :

Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1 'Pour la liste déroulante Civilité
ComboBox1.List() = Array("M.", "Mme", "Mlle")
Workbooks.Open ("C:\fichierclient.xlsx") 'ouvrir classeur fichier client
End Sub


Private Sub CommandButton1_Click()
Dim DERLIGNE As Integer


With Application.Workbooks("fichierclient.xlsx").Worksheets("feuil1")
DERLIGNE = .Range("A65536").End(xlUp).Row + 1

Feuil1.Cells(DERLIGNE, 1) = TextBox1 'code client
Feuil1.Cells(DERLIGNE, 2) = ComboBox1 'civilite
Feuil1.Cells(DERLIGNE, 3) = TextBox3 'nom
Feuil1.Cells(DERLIGNE, 4) = TextBox2 'prenom
Feuil1.Cells(DERLIGNE, 5) = TextBox5 'adresse
Feuil1.Cells(DERLIGNE, 6) = TextBox6 'code postal
Feuil1.Cells(DERLIGNE, 7) = TextBox7 'ville
Feuil1.Cells(DERLIGNE, 8) = TextBox8 'telephone
Feuil1.Cells(DERLIGNE, 9) = TextBox9 'EMAIL
End With
End Sub


je vous remercie par avance pour votre aide .
 

camarchepas

XLDnaute Barbatruc
Re : ecrire des donnees d'un userform dans un autre classeur

Bonjour,

Comme ceci peut être

Code:
Option Explicit

Private Sub UserForm_Initialize()
ComboBox1.ColumnCount = 1 'Pour la liste déroulante Civilité
ComboBox1.List() = Array("M.", "Mme", "Mlle")
Workbooks.Open ("C:\fichierclient.xlsx") 'ouvrir classeur fichier client
End Sub


Private Sub CommandButton1_Click()
Dim DERLIGNE As Long

 With Application.Workbooks("fichierclient.xlsx").Worksheets("feuil1")
   DERLIGNE = .Range("A" & Rows.Count).End(xlUp).Row + 1
  .Cells(DERLIGNE, 1) = TextBox1 'code client
  .Cells(DERLIGNE, 2) = ComboBox1 'civilite
  .Cells(DERLIGNE, 3) = TextBox3 'nom
  .Cells(DERLIGNE, 4) = TextBox2 'prenom
  .Cells(DERLIGNE, 5) = TextBox5 'adresse
  .Cells(DERLIGNE, 6) = TextBox6 'code postal
  .Cells(DERLIGNE, 7) = TextBox7 'ville
  .Cells(DERLIGNE, 8) = TextBox8 'telephone
  .Cells(DERLIGNE, 9) = TextBox9 'EMAIL
 End With
End Sub
 

camarchepas

XLDnaute Barbatruc
Re : ecrire des donnees d'un userform dans un autre classeur

Ok ,

Surement un problème d'intégration du code .

Avec un fichier c:\fichierclient cela fonctionne trés bien .

voici mon intégration
 

Pièces jointes

  • Transfert_Userform1.xlsm
    16.7 KB · Affichages: 72

Discussions similaires

Statistiques des forums

Discussions
312 321
Messages
2 087 246
Membres
103 498
dernier inscrit
FAHDE