Commander l'ouverture d'un msgbox avec un OUI

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 !

Re : Commander l'ouverture d'un msgbox avec un OUI

Bonjour mcj1997
Dans le module de la feuille, remplace
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A7")) Is Nothing Then
    UserForm1.Show
End If
End Sub
Par
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A7")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
    UserForm1.Show
End If
End Sub
Cordialement
 
Re : Commander l'ouverture d'un msgbox avec un OUI

Merci cela fonctionne, toutefois j'ai voulu l'intégrer dans mon programme et comme j'avais déjà une ligne : Private Sub Worksheet change(Byval Target As Range)
J'ai rassemblé les deux avec entre les deux commandes un End if (comme ci-dessous) et maintenant j'ai un message d'erreur suivant : Erreur de compilation End if sans bloc if.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Range("b4,d4,C9,C10,b7,d7"), Target) Is Nothing Then Call ModifC19
End If
If Not Application.Intersect(Target, Range("B5")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
UserForm1.Show
End If
If Not Application.Intersect(Target, Range("D5")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
UserForm2.Show
End If
End Sub
 
Re : Commander l'ouverture d'un msgbox avec un OUI

Re
Tu as mis
VB:
If Not Intersect(Range("b4,d4,C9,C10,b7,d7"), Target) Is Nothing Then Call ModifC19
dans ce cas là, si la condition et le then sont sur la même ligne, il ne faut de End If.
Donc:
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub

If Not Intersect(Range("b4,d4,C9,C10,b7,d7"), Target) Is Nothing Then Call ModifC19
'End If
If Not Application.Intersect(Target, Range("B5")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
    UserForm1.Show
End If

If Not Application.Intersect(Target, Range("D5")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
    UserForm2.Show
End If

End Sub

Utilise les tabulations dans ton code, c'est plus clair à relire et, pour le forum, essai d'utiliser les balises code (le bouton # quand tu fait ton post en mode avancé ;-) )

Cordialement
 
Re : Commander l'ouverture d'un msgbox avec un OUI

Re
Tu as mis
VB:
If Not Intersect(Range("b4,d4,C9,C10,b7,d7"), Target) Is Nothing Then Call ModifC19
dans ce cas là, si la condition et le then sont sur la même ligne, il ne faut de End If.
Donc:
VB:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub

If Not Intersect(Range("b4,d4,C9,C10,b7,d7"), Target) Is Nothing Then Call ModifC19
'End If
If Not Application.Intersect(Target, Range("B5")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
    UserForm1.Show
End If

If Not Application.Intersect(Target, Range("D5")) Is Nothing And _
UCase(Target.Value) = "OUI" Then
    UserForm2.Show
End If

End Sub

Utilise les tabulations dans ton code, c'est plus clair à relire et, pour le forum, essai d'utiliser les balises code (le bouton # quand tu fait ton post en mode avancé ;-) )

Cordialement



merci beaucoup
bonne journée
 
- 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
16
Affichages
602
Réponses
43
Affichages
819
Retour