Bonjour à vous,

Je viens à vous pour avoir un petit oeil externe sur un bout de code qui me donne du fil à retordre depuis quelques heures. Je bute dessus et j'ai du mal à prendre du recul pour trouver le problème.

Explications !
Je programme un gros module d'export de données comptable depuis un logiciel de compta, qui envoie un récap à des chargés de projet de leurs facturations en cours.
Ce programme fonctionne par l'intermédiaire d'un complément, pour lequel j'ai un Userform "Setup", qui permet notamment de modifier, supprimer et ajouter des chargés de projet, suivant les arrivées et départs dans l'entreprise.

Mon problème est le suivant, mon bouton d'enregistrement des valeurs modifées ne marche pas. Pourtant c'est du basique de chez basique, on affecte la valeur de la Textbox à une cellule, point final. Cela marche très bien dans le cas de l'ajout d'un chargé de projet : toutes mes cellules se remplissent comme voulu. Mais dans le cadre d'une modification de valeurs déjà saisies, mon bouton d'enregistrement fait des siennes.

J'ai un peu creusé, et je pense que le soucis provient d'un évenement que je ne vois pas, qui se déclenche en plein milieu de mon Private Sub CommandSave_click, puisque la première ligne s'effectue bien, mais pas la suite.

Je vous joins le code ainsi qu'une capture anonymisée, si vous avez des idées de ce qui pose problème ...

Si ce n'est pas assez clair, n'hésitez pas à me demander de reformuler, c'est la fin de la journée là :p

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Public nb, ind As Integer
Private Sub CommandCancel_Click()
    Unload Me
End Sub
 
Private Sub CommandDelete_Click()
    ThisWorkbook.Sheets("Liste").Rows(ind).Delete
    Call UserForm_Initialize
End Sub
 
Private Sub CommandEdit_Click()
 
If TextBoxPrenom.Enabled = False Then
 
    TextBoxPrenom.Enabled = True
    TextBoxNom.Enabled = True
    TextBoxInit.Enabled = True
    TextBoxMail.Enabled = True
    TextBoxAgence.Enabled = True
    TextBoxFACTU1.Enabled = True
    TextBoxFACTU2.Enabled = True
    TextBoxRA1.Enabled = True
    TextBoxRA2.Enabled = True
Else
    TextBoxPrenom.Enabled = False
    TextBoxNom.Enabled = False
    TextBoxInit.Enabled = False
    TextBoxMail.Enabled = False
    TextBoxAgence.Enabled = False
    TextBoxFACTU1.Enabled = False
    TextBoxFACTU2.Enabled = False
    TextBoxRA1.Enabled = False
    TextBoxRA2.Enabled = False
End If
 
End Sub
 
Private Sub CommandFile_Click()
    On Error Resume Next
    Application.FileDialog(msoFileDialogFilePicker).Show
    TextBoxFile.Value = Application.FileDialog(msoFileDialogFilePicker).SelectedItems(1)
End Sub
 
Private Sub CommandNew_Click()
 
    TextBoxPrenom.Value = ""
    TextBoxNom.Value = ""
    TextBoxInit.Value = ""
    TextBoxMail.Value = ""
    TextBoxAgence.Value = ""
    TextBoxFACTU1.Value = ""
    TextBoxFACTU2.Value = ""
    TextBoxRA1.Value = ""
    TextBoxRA2.Value = ""
 
    TextBoxPrenom.Enabled = True
    TextBoxNom.Enabled = True
    TextBoxInit.Enabled = True
    TextBoxMail.Enabled = True
    TextBoxAgence.Enabled = True
    TextBoxFACTU1.Enabled = True
    TextBoxFACTU2.Enabled = True
    TextBoxRA1.Enabled = True
    TextBoxRA2.Enabled = True
    ind = nb + 1
 
End Sub
 
Private Sub CommandSave_Click()
 
    ThisWorkbook.Sheets("Param").Range("A2").Value = TextBoxFile.Value
    With ThisWorkbook.Sheets("Liste")
        .Range("B" & ind).Value = TextBoxPrenom.Value
        .Range("A" & ind).Value = TextBoxNom.Value
        .Range("D" & ind).Value = TextBoxInit.Value
        .Range("E" & ind).Value = TextBoxMail.Value
        .Range("F" & ind).Value = TextBoxAgence.Value
        .Range("G" & ind).Value = TextBoxFACTU1.Value
        .Range("H" & ind).Value = TextBoxFACTU2.Value
        .Range("I" & ind).Value = TextBoxRA1.Value
        .Range("J" & ind).Value = TextBoxRA2.Value
    End With
 
    'Call UserForm_Initialize
End Sub
 
Private Sub ListBoxCP_Click()
    ind = ListBoxCP.ListIndex + 2
    With ThisWorkbook.Sheets("Liste")
        TextBoxPrenom.Value = .Range("B" & ind).Value
        TextBoxNom.Value = .Range("A" & ind).Value
        TextBoxInit.Value = .Range("D" & ind).Value
        TextBoxMail.Value = .Range("E" & ind).Value
        TextBoxAgence.Value = .Range("F" & ind).Value
        TextBoxFACTU1.Value = .Range("G" & ind).Value
        TextBoxFACTU2.Value = .Range("H" & ind).Value
        TextBoxRA1.Value = .Range("I" & ind).Value
        TextBoxRA2.Value = .Range("J" & ind).Value
    End With
End Sub
 
 
Private Sub UserForm_Initialize()
 
    TextBoxFile.Value = ThisWorkbook.Sheets("Param").Range("A2").Value
 
    With Setup
        .Width = 431
        .Height = 490
    End With
 
    ' Remplissage Listbox
    nb = ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
    ListBoxCP.RowSource = "[PointFactuSOLAB.xlam]Liste!C2:C" & nb
 
    TextBoxPrenom.Enabled = False
    TextBoxNom.Enabled = False
    TextBoxInit.Enabled = False
    TextBoxMail.Enabled = False
    TextBoxAgence.Enabled = False
    TextBoxFACTU1.Enabled = False
    TextBoxFACTU2.Enabled = False
    TextBoxRA1.Enabled = False
    TextBoxRA2.Enabled = False
End Sub
Nom : Sans titre.png
Affichages : 170
Taille : 27,9 Ko

Bien à vous,

Matthieu