Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Bloquer exécution USF

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Matt51100

XLDnaute Occasionnel
Bonjour à tous,

Dans le cadre d'un projet que je suis entrain de développer j'aimerais connaitre la solution au problème.

Dans un USF, j'ai un bouton qui exécute un code. Dans ce code si une certaine condition est remplie un deuxième USF est appelé. Quand ce deuxième USF est appelé j'aimerais suspendre l'exécution du code du premier USF et le reprendre lorsque je ferme le deuxième USF.

Merci d'avance.

A+, Matt.
 
Re : Bloquer exécution USF

bonjour Robert,

Voici le code :

Code:
Worksheets("Planning Travail").Activate

ech = TextBox6.Value

Dim rerech As Range

If ech = "" Then
MsgBox ("La réception des échantillons n'est attribuée à personne.")
GoTo tt
End If

Set rerech = Cells.Find(What:=ech, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)

If rerech Is Nothing Then
MsgBox (ech & " est absent(e) cette semaine. Attribuer la réception des échantillons à une autre personne")
TextBox6 = ""
GoTo tt
Else: rerech.Activate
If ActiveCell.Offset(2, -2).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, -1).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, 0).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, 1).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, 2).Interior.ColorIndex = 48 Then
[SIZE="4"]Echantillons.Show[/SIZE]
End If
End If

If ActiveCell.Offset(2, -2).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, -1).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 0).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 1).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 2).Interior.ColorIndex <> 48 Then
ActiveCell.Offset(4, -2).Select
ActiveCell = "Réception des échantillons"
With Selection.Font
        .Name = "Comic Sans MS"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleSingle
        .ColorIndex = 3
    End With
    Selection.Font.Bold = True
End If

tt:

PPI = TextBox11.Value

Dim reppi As Range

If PPI = "" Then
MsgBox ("La libération de l'eau ppi n'est attribué à personne.")
GoTo ddd
End If

Set reppi = Cells.Find(What:=PPI, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)

If reppi Is Nothing Then
MsgBox (ech & " est absent(e) cette semaine. Attribuer la libération de l'eau ppi à une autre personne")
TextBox11 = ""
GoTo ddd
Else: reppi.Activate
If ActiveCell.Offset(2, -2).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, -1).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, 0).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, 1).Interior.ColorIndex = 48 Or ActiveCell.Offset(2, 2).Interior.ColorIndex = 48 Then
[SIZE="4"]usfppi.Show[/SIZE]
End If
End If

Dim presech As String
If ActiveCell.Offset(4, -2).Value <> "" Then
presech = ActiveCell.Offset(4, -2).Value

If ActiveCell.Offset(2, -2).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, -1).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 0).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 1).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 2).Interior.ColorIndex <> 48 Then
ActiveCell.Offset(4, -2).Select
ActiveCell = presech & " et Libération eau ppi 8H00"
With Selection.Font
        .Name = "Comic Sans MS"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleSingle
        .ColorIndex = 3
    End With
    Selection.Font.Bold = True
    GoTo ddd
End If
End If

If ActiveCell.Offset(2, -2).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, -1).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 0).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 1).Interior.ColorIndex <> 48 And ActiveCell.Offset(2, 2).Interior.ColorIndex <> 48 Then
ActiveCell.Offset(4, -2).Select
ActiveCell = "Libération de l'eau ppi 8H00"
With Selection.Font
        .Name = "Comic Sans MS"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleSingle
        .ColorIndex = 3
    End With
    Selection.Font.Bold = True
End If



ddd: CommandButton2.Enabled = True

End Sub

Quand la ligne echantillons.show s'exécute mon deuxième USF s'ouvre mais le code au dela de cette ligne continue son exécution. J'en ai pour preuve que qu'un troisième USF (ligne usfppi.show) s'ouvre.

A+, Matt.
 
Re : Bloquer exécution USF

Bonjour Matt, bonjour le forum,

Oui ton code indique bien que deux UserForm peuvent s'ouvrir selon certaines conditions mais je voudrais savoir quels type de contrôles il y a dans Echantillons et/ou dans usfppi ainsi que leur code ?
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
15
Affichages
635
W
Réponses
6
Affichages
641
Réponses
5
Affichages
445
Réponses
26
Affichages
2 K
Réponses
4
Affichages
892
L
Réponses
1
Affichages
1 K
L
Réponses
2
Affichages
995
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…