bonjour
voila j'ai un petit soucis avec se code,il sert à enregistrer des données dans ma feuille.
les données s'enregistre bien dans les cellules qui leurs sont destinnées sauf la colonne "M",qui elle va bien dans la colonne "M" mais tous en bas.en plus
dans ma base j'ai des données qui vont jusqu'à la colonne "U" car dans la form principale je peut faire une mise à jour et j'envoi aussi des données dans les colonnes qui vont de "N" à "U".
j'espère avoir était assez clair car se n'est pas évident d'expliquer.
Private Sub CommandButton4_Click() 'enregistrer
Dim Msg1 As String
Dim MSG2 As String
Dim L2 As Integer
If TextBox10 = "" Then
MsgBox "Veuillez rentré un nom ? ", vbCritical, "Validation Erreur"
Exit Sub
End If
Msg1 = MsgBox("Voulez-vous ajouter cette nouvelle entrée ? " _
& vbCrLf & vbCrLf & vbTab & "Nom : " & vbTab & TextBox10 _
& vbCrLf & vbCrLf & vbTab & "Prénon : " & vbTab & TextBox11 _
& vbCrLf & vbCrLf & vbTab & "Date de Naissance : " & vbTab & TextBox13 _
& vbCrLf & vbCrLf & vbTab & "Age : " & vbTab & TextBox14 _
& vbCrLf & vbCrLf & vbTab & "Père : " & vbTab & TextBox1 _
& vbCrLf & vbCrLf & vbTab & "Mère : " & vbTab & TextBox3 _
& vbCrLf & vbCrLf & vbTab & "Adresse : " & vbTab & TextBox7 _
& vbCrLf & vbCrLf & vbTab & "Commune : " & vbTab & TextBox9 _
& vbCrLf & vbCrLf & vbTab & "Téléphone Fixe : " & vbTab & TextBox8 _
& vbCrLf & vbCrLf & vbTab & "Téléphone Portable : " & vbTab & TextBox15 _
& vbCrLf & vbCrLf & vbTab & "Employeur : " & vbTab & TextBox2, vbYesNo, "Nouveau Validation")
If Msg1 = vbYes Then
L2 = Sheets("base").Range("A65536").End(xlUp).Row + 1
With Sheets("base")
.Range("G" & L2).Value = TextBox1.Value
.Range("I" & L2).Value = TextBox2.Value
.Range("H" & L2).Value = TextBox3.Value
.Range("J" & L2).Value = TextBox7.Value
.Range("K" & L2).Value = TextBox9.Value
.Range("L" & L2).Value = TextBox8.Value
.Range("M" & L2).Value = TextBox15.Value
.Range("A" & L2).Value = TextBox10.Value
.Range("B" & L2).Value = TextBox11.Value
.Range("C" & L2).Value = TextBox12.Value
.Range("E" & L2).Value = TextBox13.Value
.Range("D" & L2).Value = ComboBox1.Value
.Range("F" & L2).FormulaLocal = "=ENT((AUJOURDHUI()-E" & L2 & ")/365)&" & Chr(34) & " ans" & Chr(34)
End With
Else: TextBox10 = ""
End If
MSG2 = MsgBox("Voulez-vous continuer pour d'autres nouvelles entrées ?", _
vbYesNo, "Nouveau Continuer ?")
If MSG2 = vbYes Then
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
TextBox11 = ""
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
TextBox12.SetFocus
Else
Unload Me
UserForm1.Show
End If
End Sub
Private Sub UserForm_Initialize()
UserForm2.Caption = "NOUVELLE ENTRÉE"
L2 = Sheets("base").Range("A65536").End(xlUp).Row
plage = Sheets("base").Range("A2:U" & L2).Address
End Sub
merci
@ plus
petchy
voila j'ai un petit soucis avec se code,il sert à enregistrer des données dans ma feuille.
les données s'enregistre bien dans les cellules qui leurs sont destinnées sauf la colonne "M",qui elle va bien dans la colonne "M" mais tous en bas.en plus
dans ma base j'ai des données qui vont jusqu'à la colonne "U" car dans la form principale je peut faire une mise à jour et j'envoi aussi des données dans les colonnes qui vont de "N" à "U".
j'espère avoir était assez clair car se n'est pas évident d'expliquer.
Private Sub CommandButton4_Click() 'enregistrer
Dim Msg1 As String
Dim MSG2 As String
Dim L2 As Integer
If TextBox10 = "" Then
MsgBox "Veuillez rentré un nom ? ", vbCritical, "Validation Erreur"
Exit Sub
End If
Msg1 = MsgBox("Voulez-vous ajouter cette nouvelle entrée ? " _
& vbCrLf & vbCrLf & vbTab & "Nom : " & vbTab & TextBox10 _
& vbCrLf & vbCrLf & vbTab & "Prénon : " & vbTab & TextBox11 _
& vbCrLf & vbCrLf & vbTab & "Date de Naissance : " & vbTab & TextBox13 _
& vbCrLf & vbCrLf & vbTab & "Age : " & vbTab & TextBox14 _
& vbCrLf & vbCrLf & vbTab & "Père : " & vbTab & TextBox1 _
& vbCrLf & vbCrLf & vbTab & "Mère : " & vbTab & TextBox3 _
& vbCrLf & vbCrLf & vbTab & "Adresse : " & vbTab & TextBox7 _
& vbCrLf & vbCrLf & vbTab & "Commune : " & vbTab & TextBox9 _
& vbCrLf & vbCrLf & vbTab & "Téléphone Fixe : " & vbTab & TextBox8 _
& vbCrLf & vbCrLf & vbTab & "Téléphone Portable : " & vbTab & TextBox15 _
& vbCrLf & vbCrLf & vbTab & "Employeur : " & vbTab & TextBox2, vbYesNo, "Nouveau Validation")
If Msg1 = vbYes Then
L2 = Sheets("base").Range("A65536").End(xlUp).Row + 1
With Sheets("base")
.Range("G" & L2).Value = TextBox1.Value
.Range("I" & L2).Value = TextBox2.Value
.Range("H" & L2).Value = TextBox3.Value
.Range("J" & L2).Value = TextBox7.Value
.Range("K" & L2).Value = TextBox9.Value
.Range("L" & L2).Value = TextBox8.Value
.Range("M" & L2).Value = TextBox15.Value
.Range("A" & L2).Value = TextBox10.Value
.Range("B" & L2).Value = TextBox11.Value
.Range("C" & L2).Value = TextBox12.Value
.Range("E" & L2).Value = TextBox13.Value
.Range("D" & L2).Value = ComboBox1.Value
.Range("F" & L2).FormulaLocal = "=ENT((AUJOURDHUI()-E" & L2 & ")/365)&" & Chr(34) & " ans" & Chr(34)
End With
Else: TextBox10 = ""
End If
MSG2 = MsgBox("Voulez-vous continuer pour d'autres nouvelles entrées ?", _
vbYesNo, "Nouveau Continuer ?")
If MSG2 = vbYes Then
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
TextBox11 = ""
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
TextBox12.SetFocus
Else
Unload Me
UserForm1.Show
End If
End Sub
Private Sub UserForm_Initialize()
UserForm2.Caption = "NOUVELLE ENTRÉE"
L2 = Sheets("base").Range("A65536").End(xlUp).Row
plage = Sheets("base").Range("A2:U" & L2).Address
End Sub
merci
@ plus
petchy