Bonjour,
Je souhaite automatiser la saisie d'un document, afin d'uniformiser le contenu des cellules, pour améliorer les extractions.
Pour celà, j'ai automatisé une vérification à la fin de la saisie, et je me retrouve face à un problème :
Si une des cellules d'une ligne est déjà occupée, ça enregistre automatiquement la saisie sur la cellule du dessous.
Je ne vois pas trop comment faire pour :
Contrôler que la ligne est entièrement vide.
Enregistrer sur cette ligne toute la saisie en cours.
Voici le code que j'utilise actuellement.
A chaque usf, un contrôle est exécuté sur la colonne concernée, et enregistre l'usf sur la cellule vide suivante.
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 Private Sub enregistrer_Click() ThisWorkbook.Save If Me.Conseiller = "" Then MsgBox "Le champ Conseiller est obligatoire" Me.Conseiller.SetFocus Exit Sub Else InsMot = Worksheets("Injustifié").Range("A65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("A" & InsMot).Value = UserForm1.Conseiller.Value UserForm1.Conseiller.Value = "" End If If Me.DateZone = "" Then MsgBox "Le champ Date est obligatoire" Me.DateZone.SetFocus Exit Sub Else InsMot = Worksheets("Injustifié").Range("B65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("B" & InsMot).Value = UserForm1.DateZone.Value UserForm1.DateZone.Value = "" End If If Me.Telephone = "" Then MsgBox "Le champ Telephone est obligatoire" Exit Sub Else InsMot = Worksheets("Injustifié").Range("C65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("C" & InsMot).Value = UserForm1.Telephone.Value UserForm1.Telephone.Value = "" End If If Me.service = "" Then MsgBox "Le champ Service est obligatoire" Exit Sub Else InsMot = Worksheets("Injustifié").Range("D65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("D" & InsMot).Value = UserForm1.service.Value UserForm1.service.Value = "" End If If Me.Injustifie = "" Then MsgBox "Le champ Cause Injustifié est obligatoire" Me.Injustifie.SetFocus Exit Sub Else InsMot = Worksheets("Injustifié").Range("E65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("E" & InsMot).Value = UserForm1.Injustifie.Value UserForm1.Injustifie.Value = "" End If InsMot = Worksheets("Injustifié").Range("F65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("F" & InsMot).Value = UserForm1.N1_Precision.Value UserForm1.N1_Precision.Value = "" InsMot = Worksheets("Injustifié").Range("G65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("G" & InsMot).Value = UserForm1.Log_Anonyme.Value UserForm1.Log_Anonyme.Value = "" InsMot = Worksheets("Injustifié").Range("H65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("H" & InsMot).Value = UserForm1.Site.Value UserForm1.Site.Value = "" InsMot = Worksheets("Injustifié").Range("I65536").End(xlUp).Row + 1 Worksheets("Injustifié").Range("I" & InsMot).Value = UserForm1.Commentaire.Value UserForm1.Commentaire.Value = "" ThisWorkbook.Save End Sub
Il faudrait certainement vérifier une ligne plutôt qu'une colonne, mais je ne vois pas la solution.
Cordialement, Jérôme D
Partager