Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.
  • Initiateur de la discussion Initiateur de la discussion fortbelin
  • Date de début Date de début

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 !

F

fortbelin

Guest
Bonjour à toutes et à tous.

J'ai deux vba qui fonctionne bien dans deux classeurS différents mais quand je veux les mettre dans le même classeur, elle ne marche plus. Merci pour votre aide

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("I4:AE4,I14:AE14")) Is Nothing Then

With Target.Interior
If .Pattern = xlUp Then
.Pattern = xlNone
Else
.PatternColorIndex = 44
.Pattern = xlUp
End If
End With

End If
End Sub


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("J6:L6")) Is Nothing Then
With Target
If Selection.Interior.ColorIndex = 48 Then
Selection.Interior.ColorIndex = xlNone
Else
Selection.Interior.ColorIndex = 48
End If
End With
End If
End Sub

fortbelin
Utilisateur occasionnel

Messages: 23
Inscription: 23 Sep 2011, 17:12
Version Excel: 2003
 
Re : Fusion de VBA

Re,

pour les regrouper :
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("I4:AE4,I14:AE14")) Is Nothing Then

With Target.Interior
If .Pattern = xlUp Then
.Pattern = xlNone
Else
.PatternColorIndex = 44
.Pattern = xlUp
End If
End With

End If
If Not Application.Intersect(Target, Range("J6:L6")) Is Nothing Then
With Target
If .Interior.ColorIndex = 48 Then
.Interior.ColorIndex = xlNone
Else
.Interior.ColorIndex = 48
End If
End With
End If
End Sub
 
Re : Fusion de VBA

Bonjour Fortbelin.

Essaie plutôt ça :


Oups ! Bonjour Pierrot.
 
Re : Fusion de VBA

Bonjour tout le monde 🙂,
Que de collisions 😛...
Allez, une de plus
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
With Target.Interior
    If Not Intersect(Target, Range("I4:AE4,I14:AE14")) Is Nothing Then
        If .Pattern = xlUp Then
            .Pattern = xlNone
        Else
            .PatternColorIndex = 44
            .Pattern = xlUp
        End If
    ElseIf Not Intersect(Target, Range("J6:L6")) Is Nothing Then
        If .ColorIndex = 48 Then
            .ColorIndex = xlNone
        Else
            .ColorIndex = 48
        End If
    End If
End With
End Sub
Bonne suite 😎
 
- 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
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

Réponses
14
Affichages
484
Réponses
9
Affichages
508
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
1 K
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…