Microsoft 365 Ligne et colonne surlignée

Claudy

XLDnaute Accro
Bonsoir, j'ai récupérer ce code ci dessous pour surligner la ligne de ma cellule active:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim champ As Range

Dim col1 As Double

Dim col2 As Double

Set champ = Range("A2:K133000")

If Not Intersect(Range("A2:N133000"), Target) Is Nothing And Target.Count = 1 Then

champ.Interior.ColorIndex = xlNone

col1 = champ.Column

col2 = col1 + champ.Columns.Count - 1

Range(Cells(Target.Row, col1), Cells(Target.Row, col2)).Resize(Selection.Rows.Count).Interior.ColorIndex = 36


'Range(Cells(Target.Row, col1), Cells(Target.Row, col2)).Interior.ColorIndex = 36

End If

End Sub

ça fonctionne très bien sur la ligne, mais je voudrais aussi adapter pour la colonne...
Merci pour votre aide,
Claudy
 

Jacky67

XLDnaute Barbatruc
Bonsoir, j'ai récupérer ce code ci dessous pour surligner la ligne de ma cellule active:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim champ As Range

Dim col1 As Double

Dim col2 As Double

Set champ = Range("A2:K133000")

If Not Intersect(Range("A2:N133000"), Target) Is Nothing And Target.Count = 1 Then

champ.Interior.ColorIndex = xlNone

col1 = champ.Column

col2 = col1 + champ.Columns.Count - 1

Range(Cells(Target.Row, col1), Cells(Target.Row, col2)).Resize(Selection.Rows.Count).Interior.ColorIndex = 36


'Range(Cells(Target.Row, col1), Cells(Target.Row, col2)).Interior.ColorIndex = 36

End If

End Sub

ça fonctionne très bien sur la ligne, mais je voudrais aussi adapter pour la colonne...
Merci pour votre aide,
Claudy
Bonjour,
On pourrait presque s'inspiré de l'exemple en PJ réalisé par MFC
 

Pièces jointes

  • LigneET colonneENcouleur.xlsm
    38.6 KB · Affichages: 9

Claudy

XLDnaute Accro
Ok merci mais ton nom "Colonne" il est définit comment?
1575747287560.png
 

Discussions similaires

Statistiques des forums

Discussions
311 720
Messages
2 081 896
Membres
101 833
dernier inscrit
sandra25