Keep current line visible when losing focus in Microsoft Excel

In Microsoft Excel the current selection is not visible focus is on another window, it very boring when working with multiple screens. With a simple Macro we can have a workaround.

The Macro simply change the background color to yellow of the current line.

NB: this Macro overrides the preset background color.

Follow these steps to add the Macro :
2014-09-24_14h54_15

Private previousActive As String

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If previousActive = Empty Then
        previousActive = "A1"
    End If

    Range(previousActive).EntireRow.Interior.ColorIndex = "0"
    ActiveCell.EntireRow.Interior.ColorIndex = "6"
    previousActive = ActiveCell.Address
End Sub

Result :

2014-09-24_14h52_39

Source

Edit (2015-02-10):

And there is the code to change the color of the current line and column in red :

Private previousActive As String

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If previousActive = Empty Then
        previousActive = "A1"
    End If
    Range(previousActive).EntireRow.Font.Color = 0
    Range(previousActive).EntireColumn.Font.Color = 0
    ActiveCell.EntireRow.Font.Color = 255
    ActiveCell.EntireColumn.Font.Color = 255
    previousActive = ActiveCell.Address
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.