XL 2016 [RESOLU] Surlignage

GADENSEB

XLDnaute Impliqué
bonjour le Forum
J'ai développé cette macro qui me permet de surligner une ligne en cliquant dessus.
si je clique sur une autre ligne la mef de la premiére ligne revient à la normal etc …...

je voudrais y apporter deux améliorations :
- limiter la macro à partir de la ligne 3
- Limiter la macro aux colonne A:J

Qqn aurais une idée ?


RAJOUT : on peut dire aussi que l'action peut se limiter uniquement au tableau de données appelé "Tableau1"

Bonne am ?
SEB



VB:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static AncAdress As Long
'Si la fonction activer/Déactiver est implémentée ajouter la ligne ci-dessous
    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
        Rows.Interior.ColorIndex = xlNone
        Rows.Font.ColorIndex = 0
       
    End If
    Target.EntireRow.Font.ColorIndex = 6
    Target.EntireRow.Interior.ColorIndex = 3
    Target.EntireRow.Interior.Pattern = xlSolid
      AncAdress = Target.Row

       
   
End Sub
 
Dernière édition:

sylvanu

XLDnaute Barbatruc
Supporter XLD
remplacer les trois lignes où il y a Target.EntireRow par :
VB:
    Range(Cells(Target.Row, 1), Cells(Target.Row, 10)).Font.ColorIndex = 6
    Range(Cells(Target.Row, 1), Cells(Target.Row, 10)).Interior.ColorIndex = 3
    Range(Cells(Target.Row, 1), Cells(Target.Row, 10)).Interior.Pattern = xlSolid
ce qui limite le champs d'action aux 10 premières colonnes, soit A:J.