Bonjour,

J'ai créé un formaulaire (yes !)
Mais je voudrais mettre une condition sur une cellule si elle n'est pas renseignée. En gros lorsque l'utilisateur valide le formulaire si la cellule opérateur n'est pas renseignée alors le message lui dit "il faut renseigner l'opérateur".
J'ai réussi mais le problème c'est qu'une fois le message affiché, il enregistre les données. Moi je voudrais rester sur le formulaire et qu'il me positionne dans la case incriminée.

Voici mon code :
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
Sub enregistre()
 
    Dim EntreePlus As Worksheet, ZZ As Range, Erg, i As Integer, AA As Range, BB As Range, EE As Range, XX As Range, YY As Range, FF As Range, GG As Range, HH As Range, II As Range, JJ As Range, KK As Range, LL As Range, MM As Range, NN As Range, OO As Range
 
    Set EntreePlus = ThisWorkbook.Worksheets("donnees")
 
    Application.ScreenUpdating = True
 
    If UserForm1.ComboBox1.Value = "" Then
        MsgBox "Veuillez renseigner le nom de l'opérateur!"
    End If
 
    Set XX = EntreePlus.Cells(16384, 1).End(xlUp).Offset(1, 0) 'Date
    Set ZZ = EntreePlus.Cells(16384, 2).End(xlUp).Offset(1, 0) 'Opérateur
    Set YY = EntreePlus.Cells(16384, 3).End(xlUp).Offset(1, 0) 'Plante utilisée
    Set AA = EntreePlus.Cells(16384, 4).End(xlUp).Offset(1, 0) 'Code produit de la plante utilisée
    Set BB = EntreePlus.Cells(16384, 5).End(xlUp).Offset(1, 0) 'N° de lot
    Set EE = EntreePlus.Cells(16384, 6).End(xlUp).Offset(1, 0) 'Quantité entrée
    Set GG = EntreePlus.Cells(16384, 7).End(xlUp).Offset(1, 0) 'Quantité sortie
    'Set HH = EntreePlus.Cells(16384, 8).End(xlUp).Offset(1, 0) 'Quantité sortie coupée menue
    'Set II = EntreePlus.Cells(16384, 9).End(xlUp).Offset(1, 0) 'Quantité sortie coupe infusette
    'Set JJ = EntreePlus.Cells(16384, 10).End(xlUp).Offset(1, 0) 'Quantité sortie poudre
    'Set KK = EntreePlus.Cells(16384, 11).End(xlUp).Offset(1, 0) 'Quantité sortie brisure
    Set LL = EntreePlus.Cells(16384, 8).End(xlUp).Offset(1, 0) 'Temps passé
    Set MM = EntreePlus.Cells(16384, 9).End(xlUp).Offset(1, 0) 'Matériel utilisé
    Set NN = EntreePlus.Cells(16384, 10).End(xlUp).Offset(1, 0) 'Opération
    Set OO = EntreePlus.Cells(16384, 11).End(xlUp).Offset(1, 0) 'Perte
    Set PP = EntreePlus.Cells(16384, 12).End(xlUp).Offset(1, 0) 'Rendement
    Set QQ = EntreePlus.Cells(16384, 13).End(xlUp).Offset(1, 0) 'Commentaire
 
 
 
    XX.Offset(0, i).Value = UserForm1.TextBox1.Text 'Format(UserForm1.TextBox1, "dd/MM/yyyy")
    ZZ.Offset(0, i).Value = UserForm1.ComboBox1.Value
    YY.Offset(0, i).Value = UserForm1.ComboBox2.Value
    AA.Offset(0, i).Value = UserForm1.TextBox3.Text
    BB.Offset(0, i).Value = UserForm1.TextBox4.Text
    EE.Offset(0, i).Value = UserForm1.TextBox5.Text
    GG.Offset(0, i).Value = UserForm1.TextBox6.Text
    'HH.Offset(0, i).Value = UserForm1.TextBox7.Text
    'II.Offset(0, i).Value = UserForm1.TextBox8.Text
    'JJ.Offset(0, i).Value = UserForm1.TextBox9.Text
    'KK.Offset(0, i).Value = UserForm1.TextBox10.Text
    LL.Offset(0, i).Value = (UserForm1.TextBox11.Text) + ((UserForm1.TextBox12.Text) / 60)
    MM.Offset(0, i).Value = UserForm1.ComboBox3.Value
    NN.Offset(0, i).Value = UserForm1.ComboBox4.Value
    OO.Offset(0, i).Value = ((UserForm1.TextBox5.Text) - (UserForm1.TextBox6.Text)) / (UserForm1.TextBox5.Text)
    PP.Offset(0, i).Value = (UserForm1.TextBox6.Text) / ((UserForm1.TextBox11.Text) + ((UserForm1.TextBox12.Text) / 60))
    QQ.Offset(0, i).Value = UserForm1.TextBox2.Value
 
 
Unload UserForm1
 
Application.ScreenUpdating = True
 
    MsgBox "Les données ont été enregistrées avec succés"
 
End Sub
Est ce que quelqu'un peut m'aider ?

Merci

Nini