Probleme avec mon userform
R
Bonjour
ci joint mon fichier excell pour qui j ai cree un userform dont les champs de saisie doivent s enregistrer dans la base de données ( feuilles base de données ). Pour tous mes champs de saise ca va bien , il n'y a que les case d'options qui me causent probleme
je ne sais pas quel code ecrire pour que le resultat qui est pointé ( a savoir depot, retrait ou virement ) se copie dans la colonne 1 de la base de données comme le font toutes les autres valeurs ..je copie ici le code utilisé ..j imagine que ce n est qu 'une petite ligne a ajouter mais la je bloque ..je sais pas comment faire
Dim ws As Worksheet
Dim prochaineLigne As Long
Set ws = ThisWorkbook.Sheets("Base de données")
prochaineLigne = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1
If prochaineLigne < 3 Then prochaineLigne = 3
ws.Cells(prochaineLigne, 1).Value = CDate(txtDate.Value)
ws.Cells(prochaineLigne, 6).Value = CDbl(txtMontant.Value)
ws.Cells(prochaineLigne, 10).Value = txtDescription.Value
ws.Cells(prochaineLigne, 5).Value = cbo1.Value
ws.Cells(prochaineLigne, 3).Value = cbo2.Value
ws.Cells(prochaineLigne, 4).Value = cbo3.Value
ws.Cells(prochaineLigne, 7).Value = cbo4.Value
ws.Cells(prochaineLigne, 8).Value = cbo5.Value
ws.Cells(prochaineLigne, 9).Value = cbo6.Value
If chkMode.Value Then
ws.Cells(prochaineLigne, 11).Value = "Oui"
Else
ws.Cells(prochaineLigne, 11).Value = "Non"
End If
Merci de me depanner
E
Bonjour,
Private Sub cmdEnregistrer_Click()
If Not IsDate(txtDate.Value) Then
MsgBox "Date invalide"
Exit Sub
End If
If Not IsNumeric(txtMontant.Value) Then
MsgBox "Montant invalide"
Exit Sub
End If
If optType1 = False And optType2 = False And optType3 = False Then
MsgBox "Sélectionner un type d'opération !", vbCritical
Exit Sub
End If
Dim ws As Worksheet
Dim prochaineLigne As Long
Set ws = ThisWorkbook.Sheets("Base de données")
prochaineLigne = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row + 1
If prochaineLigne < 3 Then prochaineLigne = 3
ws.Cells(prochaineLigne, 1).Value = CDate(txtDate.Value)
ws.Cells(prochaineLigne, 6).Value = CDbl(txtMontant.Value)
ws.Cells(prochaineLigne, 10).Value = txtDescription.Value
ws.Cells(prochaineLigne, 5).Value = cbo1.Value
ws.Cells(prochaineLigne, 3).Value = cbo2.Value
ws.Cells(prochaineLigne, 4).Value = cbo3.Value
ws.Cells(prochaineLigne, 7).Value = cbo4.Value
ws.Cells(prochaineLigne, 8).Value = cbo5.Value
ws.Cells(prochaineLigne, 9).Value = cbo6.Value
If optType1 Then ws.Cells(prochaineLigne, 2) = "Retrait"
If optType2 Then ws.Cells(prochaineLigne, 2) = "Dépôt"
If optType3 Then ws.Cells(prochaineLigne, 2) = "Virement"
If chkMode.Value Then
ws.Cells(prochaineLigne, 11).Value = "Oui"
Else
ws.Cells(prochaineLigne, 11).Value = "Non"
End If
ChargerHistorique
EffacerFormulaire
Set ws = Nothing
MsgBox "Enregistrement complété"
End SubR
Super ! merci