Aide sur "Worksheet_Change"

Flop

XLDnaute Occasionnel
Bonjour à tous, voici la macro que j'ai, et j'arrive pas a la faire fonctionner correctement, je m'explique pour la 1er partie, dans la feuille en question, dans la cellule I11 j'ai une liste déroule avec plusieurs choix "toto", "toto en voyage", "titi", j'aimerais que quand l'utilisateur selectionne "toto" cela lance la macro "toto" et ainsi de suite, la macro ci dessous fonctionne pour lancer une macro mais j'arrive pas la faire fonctionner en fonction du choix, merci d'avance. :)

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$I$11" = "TOTO" Then
    
    'on lance la procédure Toto
    Call toto
       
End If


If Intersect(Target, [H14:H27]) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True



End Sub
 

Flop

XLDnaute Occasionnel
Re : Aide sur "Worksheet_Change"

encore un petit hic pour essayer d'améliorer mon code ; ci joint mon code, quand je prends chaque morceau indépendament ca marche mais tous ensemble ne marche pas, je pense que ca vient de "Is Nothing Then Exit Sub" mais j'arrive pas à trouver le problème, merci de votre aide.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
Application.DisplayAlerts = False

If Target.Address = "$I$11" Then
    Select Case Target.Value
        Case "toto"
            Call toto 'on lance la procédure Toto
        Case "titi"
            Call titi
        Case "tata"
            Call tata

     End Select
End If

If Intersect(Target, [I14:I27]) Is Nothing Then Exit Sub
MsgBox "toto"

If Intersect(Target, [H14:H27]) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target = UCase(Target)
Application.EnableEvents = True

End Sub
 

Flop

XLDnaute Occasionnel
Re : Aide sur "Worksheet_Change"

Dommage je pensais m'être pas trop mal exprimé..
je la refait :

donc le code doit avoir 3 actions :

PARTIE 1 'LANCE LA MACRO CORRESPONDANTE AU CHOIX DE LA CELLULE I11

PARTIE 2 'TRANSFORME EN MAJUSCULE TOUT CE QUI EST TAPE DANS LA PLAGE H14:H27

'PARTIE 3 'SI IL Y A UN CHANGEMENT DANS LA PLAGE I14:I27 je lance le message

chacune de ces codes fonctionne seul. Mais dans le code qui suit, la partie 2 fonctionne mais pas la 3 si je mets en commantaires la partie 2, la partie 3 fonctionne.. voila et la soluce que tu m'a donné ne change pas mon soucis. en esperant avoir été plus clair cette fois ci :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    
Application.DisplayAlerts = False

'---------------------------------------------------------------------------
'PARTIE 1 'LANCE LA MACRO CORRESPONDANTE AU CHOIX DE LA CELLULE I11
'---------------------------------------------------------------------------
If Target.Address = "$I$11" Then
    Select Case Target.Value
        Case "toto"
            Call toto 'on lance la procédure Toto
        Case "titi"
            Call titi
        Case "tata"
            Call tata

     End Select
End If

'---------------------------------------------------------------------------
'PARTIE 2 'TRANSFORME EN MAJUSCULE TOUT CE QUI EST TAPE DANS LA PLAGE H14:H27
'--------------------------------------------------------------------------
'If Intersect(Target, [H14:H27]) Is Nothing Then Exit Sub
'Application.EnableEvents = False
'Target = UCase(Target)
'Application.EnableEvents = True
'---------------------------------------------------------------------------
'PARTIE 3 'SI IL Y A UN CHANGEMENT DANS LA PLAGE I14:I27 je lance le message
'--------------------------------------------------------------------------
If Intersect(Target, [I14:I27]) Is Nothing Then Exit Sub
MsgBox "toto"

End Sub
 

pierrejean

XLDnaute Barbatruc
Re : Aide sur "Worksheet_Change"

Re

A tester et en supposant que j'aie compris

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 
Application.DisplayAlerts = False
 
'---------------------------------------------------------------------------
'PARTIE 1 'LANCE LA MACRO CORRESPONDANTE AU CHOIX DE LA CELLULE I11
'---------------------------------------------------------------------------
If Target.Address = "$I$11" Then
Select Case Target.Value
Case "toto"
Call toto 'on lance la procédure Toto
Case "titi"
Call titi
Case "tata"
Call tata
 
End Select
End If
 
'---------------------------------------------------------------------------
'PARTIE 2 'TRANSFORME EN MAJUSCULE TOUT CE QUI EST TAPE DANS LA PLAGE H14:H27
'--------------------------------------------------------------------------
Application.EnableEvents = False
 if not intersect (Target,Range("H14:H27") is nothing then
  for each cel in Range("H14:H27" )
   Target = UCase(Target)
  next cel
 End if
Application.EnableEvents = True
'---------------------------------------------------------------------------
'PARTIE 3 'SI IL Y A UN CHANGEMENT DANS LA PLAGE I14:I27 je lance le message
'--------------------------------------------------------------------------
If [COLOR=blue]Not[/COLOR] Intersect(Target, [I14:I27]) Is Nothing Then Exit Sub
MsgBox "toto"
 

Flop

XLDnaute Occasionnel
Re : Aide sur "Worksheet_Change"

ca ne fonctionne pas.. j'avais la ligne

if not intersect (Target,Range("H14:H27") is nothing then

en rouge j'ai rajouté la paranthese ici

if not intersect (Target,Range("H14:H27")) is nothing then

ca ne marchait pas ca me convertissait bien la plage H14:H27 en majuscule mais ca déclenché quand meme la partie 3 je l'ai modifié comme ca et ca fonctionne :

Code:
'---------------------------------------------------------------------------
'PARTIE 3 'SI IL Y A UN CHANGEMENT DANS LA PLAGE I14:I27 je lance le message
'--------------------------------------------------------------------------
If Not Intersect(Target, [I14:I27]) Is Nothing Then
MsgBox "toto"

End If
 

Discussions similaires

Statistiques des forums

Discussions
312 775
Messages
2 092 023
Membres
105 152
dernier inscrit
pago