Boucle dans et sur USERFORM
Bonjour à tous,
Je vous expose mon Pb, j'ai créé une Userform pour rentré des données utilisé dans la Userform,
et je cherche à faire de paramètres de validation avant exécution. C'est la que mon PB ce pose avec seulement des paramètre if/end if ça marche très bien, mais je voudrais que mon Userform ce relance si les paramètre ne sont pas valide.
voici le code effectué après appel simple sur un bouton de ruban par .show
Code:
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 annul_button_Click()
Unload Me
End Sub
Private Sub ligne_fin_Change()
End Sub
Private Sub ligne_init_Change()
End Sub
Private Sub ok_button_Click()
Dim i As Integer
Dim form As String
Dim k As Integer
Dim l As Integer
If ActiveSheet.Name <> "Etude" And ActiveSheet.Name <> "Etude opt" Then
MsgBox "Selection non valide pour cette opération", vbCritical
Else:
k = RechercherLignesDebutOuFin("Deb")
l = RechercherLignesDebutOuFin("Fin")
Do While (ligne_init = 0 Or ligne_fin = 0)
If ligne_init.Value = "" Then GoTo fin
If ligne_fin.Value = "" Then GoTo fin
If (IsNumeric(ligne_init.Value) = False) Then ligne_init = 0
If (IsNumeric(ligne_fin.Value) = False) Then ligne_fin = 0
If (ligne_init.Value.Value < 0) Or (ligne_init.Value - Int(ligne_init.Value) <> 0) Then ligne_init = 0
If (ligne_fin.Value < 0) Or (ligne_fin.Value - Int(ligne_fin.Value) <> 0) Then ligne_fin = 0
If ligne_init.Value < ligne_fin.Value Then ligne_init = 0 And ligne_fin = 0
If ligne_fin.Value < l Then ligne_fin = 0
If ligne_init.Value > k Then ligne_init = 0
Loop
ActiveSheet.Unprotect
Application.ScreenUpdating = False
form = "O" & ligne_init.Value & "*N" & ligne_init.Value
For i = ligne_init.Value + 1 To ligne_fin.Value
form = form & "+O" & i & "*N" & i
Next i
Range("M" & ligne_init.Value - 1).Value = "Ens."
Range("N" & ligne_init.Value - 1).Value = 1
Range("O" & ligne_init.Value - 1).Formula = "=round(" & "(" & form & ")" & "/" & "n" & ligne_init.Value - 1 & ",nbarpu)"
Range("P" & ligne_init.Value - 1).Value = "=round(" & "O" & ligne_init.Value - 1 & "*" & "n" & ligne_init.Value - 1 & ",2)"
Range("P" & ligne_init.Value & ":P" & ligne_fin.Value).ClearContents
Range("M" & ligne_init.Value & ":O" & ligne_fin.Value).Font.ColorIndex = 2
Rows(ligne_init.Value & ":" & ligne_fin.Value).Select
Selection.Rows.Group
Application.ScreenUpdating = True
ActiveSheet.Protect
Else:
MsgBox "Paramètres non valides", vbCritical
End If
fin:
End If
Unload Me
End Sub |
merci de votre aide et de votre temps passé.
CRDL.