Bonjour à tous,
Je suis en train de travailler sur un fichier excel permettant de faire des remontées d'anomalies.
Ces dernières se font grâce à un formulaire (avec textbox + combobox).
Elles alimentent un tableau où je souhaite qu'il n'y ait pas de doublons.
Exemple :
J'ai 10 cases à remplir dans mon formulaire pour alimenter les 10 colonnes (de B à K) de mon tableau
Si deux lignes ont des valeurs identiques dans les colonnes D, E, F, G et I alors, elles sont considérées comme deux lignes doublons et je souhaite que cela n'arrive pas.
Je me suis donc créer un module :
Enfin, quand je valide mon formulaire, voici ce que fait mon bouton de validation :
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 Sub eliminer_doublons() Sheets("Feuil5").Activate Sheets("Feuil5").Range("D3").Select Do Until ActiveCell = UserForm1.ComboBox1.Value Or ActiveCell = "" ActiveCell.Offset(1, 0).Select Loop If ActiveCell = UserForm1.ComboBox1.Value Then Sheets("Feuil5").Range("E3").Select Do Until ActiveCell = UserForm1.ComboBox2.Value Or ActiveCell = "" ActiveCell.Offset(1, 0).Select Loop If ActiveCell = UserForm1.ComboBox2.Value Then Sheets("Feuil5").Range("F3").Select Do Until ActiveCell = UserForm1.ComboBox3.Value Or ActiveCell = "" ActiveCell.Offset(1, 0).Select Loop If ActiveCell = UserForm1.ComboBox3.Value Then Sheets("Feuil5").Range("G3").Select Do Until ActiveCell = UserForm1.TextBox4.Value Or ActiveCell = "" ActiveCell.Offset(1, 0).Select Loop If ActiveCell = UserForm1.TextBox4.Value Then Sheets("Feuil5").Range("H3").Select Do Until ActiveCell = UserForm1.ComboBox4.Value Or ActiveCell = "" ActiveCell.Offset(1, 0).Select Loop If ActiveCell = UserForm1.ComboBox4.Value Then MsgBox "Cette anomalie a déjà été remontée." Else MsgBox "Merci ! Votre anomalie a bien été remontée." End If End If End If End If End If End Sub
Quand je créé une ligne doublon dans le formulaire et que je clique sur le bouton de validation, j'ai le MsgBox "Merci ! Votre anomalie a bien été remontée." qui apparaît, POURTANT ma ligne ne s'est pas insérée dans le tableau...
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 Private Sub CommandButton1_Click() If TextBox1 = "" Or TextBox2 = "jj/mm/aaaa" Or TextBox4 = "" Or TextBox5 = "" Or ComboBox1 = "Sélectionner une Enseigne" Or ComboBox2 = "Sélectionner un Entrepôt" Or ComboBox3 = "Sélectionner une Strate" Or ComboBox4 = "" Or ComboBox5 = "" Then MsgBox ("Toutes les informations ne sont pas remplies.") Else If Sheets("Feuil5").Range("B3") = "" Then Sheets("Feuil5").Range("B3") = TextBox1 Else If Sheets("Feuil5").Range("B3") <> "" Then eliminer_doublons Else Sheets("Feuil5").ListObjects(1).ListRows.Add End If End If Dlt = Sheets("Feuil5").Range("D1048576").End(xlUp).Row Sheets("Feuil5").Range("B" & Dlt) = TextBox1 Sheets("Feuil5").Range("C" & Dlt) = TextBox2.Value TextBox2.Value = Format(TextBox2, "mm/dd/yyyy") Sheets("Feuil5").Range("D" & Dlt) = ComboBox1 Sheets("Feuil5").Range("E" & Dlt) = ComboBox2 Sheets("Feuil5").Range("F" & Dlt) = ComboBox3 Sheets("Feuil5").Range("G" & Dlt) = TextBox4 Sheets("Feuil5").Range("H" & Dlt) = TextBox5 Sheets("Feuil5").Range("I" & Dlt) = ComboBox4 Sheets("Feuil5").Range("J" & Dlt) = ComboBox5 Unload UserForm1 End If End Sub
Pouvez-vous m'aider
Merci par avance, n'hésitez pas si besoin du fichier !
Bonne journée,
ClemenceI
Partager