bonjour,
Mon UserForm me permet de faire un control de saisie s'il manque une info. Tout fonctionne sauf que si j'oublie de remplir une TextBox
le message "Saisie incomplète !" apparait bien, je clique sur Ok, et là mon userform se ferme alors que je devrais retrouner sur ce dernier.
Voici ce que j'ai écris
Private Sub CmdOK_Click()
Dim Ctl As Control
Dim Lign As Long
Dim Flag As Boolean
For Each Ctl In Me.Controls
If TypeOf Ctl Is MSForms.TextBox Then
If Ctl.Text = "" Then
MsgBox "Saisie incomplète !"
With Ctl
.BorderStyle = 1
.BackColor = RGB(241, 221, 220)
.BorderColor = RGB(255, 0, 0)
.SetFocus
End With
Flag = True
Exit For
End If
End If
Next Ctl
If Not Flag Then
With Worksheets("Listes")
Lign = .Cells(.Rows.Count, "K").End(xlUp).Row + 1
.Cells(Lign, 11) = TxtBoxCategorie
With .Cells(Lign, 12)
.Value = TxtBoxValidite
.HorizontalAlignment = xlCenter
End With
End With
End If
Trie_categorie
UserForm2.Ajout_Categorie
Unload Me
End Sub
Pouvez-vous me dire comment faire ?
Merci
Frederique