XL 2019 surlignage ligne

  • Initiateur de la discussion Initiateur de la discussion bambi
  • 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 !

bambi

XLDnaute Occasionnel
Bonjour

J'ai adapté une macro de surlignage trouvée sur ce forum
Le surlignage est actif sur la ligne selectionnée afin de la mettre en valeur
Je surligne de la ligne 23 à la colonne 40
Mais j'ai des données formatées au-dessus de la ligne 23
Et cette macro supprime TOUT le formatage de la feuille
Est-il possible de conserver la mise en forme au dessus de la ligne 23 ?

Voici ma macro et un classeur exemple

Merci de votre aide

VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static AncAdress As Long
    If Target.Row < 23 Or Target.Column > 41 Then Exit Sub
    If ActivationLigne Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    If AncAdress <> 0 Then 'remettre en normal
        Rows.Interior.ColorIndex = xlNone
        Rows.Font.ColorIndex = 0
      
    End If
    
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Font.ColorIndex = 1
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Interior.ColorIndex = 19
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Interior.Pattern = xlSolid

      AncAdress = Target.Row
  
End Sub
 

Pièces jointes

Solution
Bonjour,

Ceci:
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static AncAdress As Long
    If Target.Row < 23 Or Target.Column > 41 Then Exit Sub
    If ActivationLigne Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    If AncAdress <> 0 Then 'remettre en normal
        Rows(AncAdress).Interior.ColorIndex = xlNone
        Rows(AncAdress).Font.ColorIndex = 0
    End If
    
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Font.ColorIndex = 1
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Interior.ColorIndex = 19
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Interior.Pattern = xlSolid
    AncAdress = Target.Row
End Sub

Cdlt
Bonjour,

Ceci:
VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static AncAdress As Long
    If Target.Row < 23 Or Target.Column > 41 Then Exit Sub
    If ActivationLigne Then Exit Sub
    If Target.Count > 1 Then Exit Sub
    If AncAdress <> 0 Then 'remettre en normal
        Rows(AncAdress).Interior.ColorIndex = xlNone
        Rows(AncAdress).Font.ColorIndex = 0
    End If
    
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Font.ColorIndex = 1
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Interior.ColorIndex = 19
    Range(Cells(Target.Row, 1), Cells(Target.Row, 40)).Interior.Pattern = xlSolid
    AncAdress = Target.Row
End Sub

Cdlt
 
- 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
4
Affichages
243
Réponses
7
Affichages
542
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
479
Réponses
1
Affichages
348
Retour