Désolé mais c'est encore moi.
A force de persévérance j'ai réussi à avoir un résultat à peu près acceptable.
Il ne me reste qu'un seul petit problème :
Lorsque je lance mon userform, ma liste déroulante ne s'affiche pas correctement, elle est d'abord vide.
Il faut que je fasse une validation vide (et donc avoir une erreur), pour qu'enfin ma liste déroulante s'affiche.
Une idée ?
Voici mon code
Option Explicit
Dim Ws As Worksheet
Private Sub Label4_Click()
End Sub
Private Sub CommandButton4_Click()
Dim I As Integer
Dim Numlignevide As Integer
ComboBox1.ColumnCount = 2 'Pour la liste déroulante
ComboBox1.List() = Array("", "Virement", "Prélèvement", "CB", "Chèque")
Set Ws = Sheets(1) 'Correspond au nom de votre onglet dans le fichier Excel
If TextBox1.Value = "" Then
MsgBox "Veuillez renseigner une date"
Else
If ComboBox1.Value = "" Then
MsgBox "Selectionner la catégorie"
Else
If TextBox3.Value = "" Then
MsgBox "Indiquez le libellé"
Else
If TextBox4.Value = "" Then
MsgBox "Indiquez le montant"
Else
If OptionButton1 = False And OptionButton2 = False Then
MsgBox "Cocher débit ou crédit"
Else
With Sheets(1)
Numlignevide = .Columns(1).Find("").Row 'on trouve la dernière ligne vide du tableau'
.Cells(Numlignevide, 1) = TextBox1.Value 'Date'
.Cells(Numlignevide, 3) = TextBox3.Value 'Libellé'
.Cells(Numlignevide, 2) = ComboBox1.Value 'Catégorie'
If OptionButton2 = True Then
.Cells(Numlignevide, 4) = TextBox4.Value 'Montant crédit'
Else
If OptionButton1 = True Then
.Cells(Numlignevide, 5) = TextBox4.Value 'Montant débit'
End If
End If
End With
MsgBox "Saisie effectuée, vous pouvez quitter"
Unload Me
UserForm1.Show
End If
End If
End If
End If
End If
End Sub
Private Sub CommandButton1_Click()
ThisWorkbook.Save
End Sub
Private Sub CommandButton3_Click()
UserForm1.Hide
End Sub
Private Sub UserForm_Click()
End Sub