Automatically highlight selected Excel row

Here’s a simple script that makes it easier to visually scan lengthy Excel spreadsheets. If you spend a lot of time in Excel spreadsheets, you’ll find this useful.

What you’ll need

  • .XLSM Excel workbook
  • Macros enabled
Excel spreadsheet with color highlighting
Excel VBA script that automatically highlights current selected row
Excel VBA script that automatically highlights current selected row

Although I like this above script, you do have to hard code a few values. Here’s another Exel video that is more straight forward. This method also highlights the columns. This video, assumes you already know how to enable the developer tab and create formulas however.

'Visual Basic for applications code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    With ThisWorkbook.Names("CurrentRow")
    .Name = "CurrentRow"
    .RefersToR1C1 = "=" & ActiveCell.Row
'above "&" should be the ampersand symbol. 
    End With

End Sub