Wednesday, October 26, 2016

Highlighting The Active Row In Excel

If long rows of numbers are numbing (pun intended) your eye balls, you can highlight entire rows. Here's all you need to do.
  1. Save your spreadsheet as a .xlsm (macro-enabled spreadsheet)
  2. Press ALT+F11
  3. Double-left-click your worksheet (e.g. Sheet1)
  4. Paste in the following nine lines of VBA code 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
Cells.Interior.ColorIndex = 0
With Target
.EntireRow.Interior.ColorIndex = 36
End With
Application.ScreenUpdating = True
End Sub

Go back to your spreadsheet and select a different cell.  The entire row of that cell is now highlighted in yellow, as shown below. If yellow isn't appealing, you can play around changing the value of the ColorIndex from 36 to other choices.  Visit the following link to see your options.

https://msdn.microsoft.com/en-us/library/cc296089(v=office.12).aspx#xlDiscoveringColorIndex_ColorIndexProperty


No comments:

Post a Comment