Bonjour, alors j'essai de renseigner des cellules avec des valeurs selon des conditions. Grâce à une aide j'ai reussi à adapter le code à ce que je veux, juste que je n'arrive pas à loger le montant que je renseigne dans la bonne cellule. Voici le code et je joint le fichier pour meilleur comprehension
Je pense que l'erreur vient de la partie en jaune
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 Private Sub CommandButton1_Click() End End Sub Private Sub CommandButton2_Click() Dim X As String Dim I As Long X = UserForm1.ComboBox1.Value If ComboBox1.Value = "" Or ComboBox2.Value = "" Or TextBox1.Value = "" Or TextBox2.Value = "" Then MsgBox ("Veuillez remplir tous les champs pour continuer") Exit Sub End If If MsgBox("Etes-vous certain de vouloir enregistrer ces nouveaux données ?", vbYesNo + vbInformation, "Demande de confirmation") = vbYes Then With Sheets(X) I = Sheets(X).Range("A:A").Find(TextBox1.Value).Row If ComboBox2.Value = "Especes" Then .Range("E" & I ).Value = CDbl(TextBox2.Value) If ComboBox2.Value = "Virement" Then .Range("F" & I ).Value = CDbl(TextBox2.Value) If ComboBox2.Value = "Carte Bancaire" Then .Range("G" & I ).Value = CDbl(TextBox2.Value) End With End If ComboBox1.Value = "" ComboBox2.Value = "" TextBox1.Value = "" TextBox2.Value = "" End Sub Private Sub UserForm_Initialize() Dim Ws As Worksheet ComboBox1.Clear For Each Ws In ThisWorkbook.Worksheets If Ws.Name <> "TB" Then ComboBox1.AddItem Ws.Name End If Next Ws Dim Plage As String With Sheets("TB") Plage = .Range("A2:A" & .Range("A65536").End(xlUp).Row).Address End With ComboBox2.RowSource = "TB!" & Plage TextBox1.Value = Now() TextBox1.Value = Format(TextBox1.Value, "dd/mm/yyyy") End Sub
Merci d'avance
Partager