0
Thanks

A few words of thanks would be greatly appreciated.

Excel - Highlight the active row





This little function highlights the row where the cursor is currently located.

Add in a module sheet:


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static AncAdress As Long
'If the function activation / deactivation is implemented add the line below

if ActivationLine then exit sub

If Target.Count > 1 Then Exit Sub
If AncAdress <> 0 Then ' restore to normal
Rows(AncAdress).Interior.ColorIndex = xlNone
Rows(AncAdress).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

Add to a general module (e.g Module1)


If you want to activate/deactivate the function:
  • Or put a button on the macro
  • Or put a shortcut

The current row will be highlighted by default, click on the button or shortcut to change its status:
Public ActivationLigne as boolean 
Sub Activate()
ActivationLigne = not ActivationLigne
end sub
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Original article published by . Translated by jak58. Latest update on by deri58.

This document, titled "Excel - Highlight the active row," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments