Bonsoir, je rencontre un petit problème avec mon code vba.
Bon j'ai donné la main à l'utilisateur pour choisir une référence si ça existe alors il peut modifier toutes les données associées à cette référence.
Le problème c'est que lorqu'il laisse un textbox vide (il veut pas modifier la valeur) l'ancienne valeur s'écrase et se remplace par le vide dans ma feuille excel.
Merci de me proposer une solution
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 Private Sub CommandButton3_Click() Dim k As Integer Dim a As Integer Dim H As Integer H = 0 a = 5 If MsgBox("Confirmez-vous la modification des données?", vbYesNo, "Confirmation") = vbYes Then '--------------------- If TextBox1.Value = "" Then Msg = "Indiquez une Désignation" MsgBox Msg '--------------------- ElseIf ComboBox4.Value = "" Then Msg = "Indiquez le type" MsgBox Msg '--------------------- ElseIf TextBox3.Value = "" Then Msg = "Indiquez une quantité valide" MsgBox Msg '--------------------- ElseIf TextBox1.Text <> "" And ComboBox4.Value <> "" And TextBox3.Value <> "" Then Sheets("Liste des commandes").Select While Range("C" & a).Value <> "" a = a + 1 Wend For k = 6 To a If TextBox25.Text = Range("C" & k).Value And ComboBox5.Value = Range("A" & k).Value Then H = k End If Next '----------- If H = 0 Then MsgBox ("La référence n'existe pas dans la liste des commandes") Else: Sheets("Liste des commandes").Select Range("B" & H).Value = ComboBox4.Value Range("D" & H).Value = TextBox3.Value Range("A" & H).Value = TextBox1.Value Range("E" & H).Value = TextBox12.Value Range("G" & H).Value = TextBox10.Value Range("F" & H).Value = ComboBox1.Value & ComboBox2.Value & ComboBox3.Value 'ComboBox5.Clear 'TextBox25.Value = "" End If '---------------------- End If Else ComboBox5.Clear TextBox25.Value = "" End If End Sub
Partager