Globally Highlight Current Row in Color
Posted by Mark P. Medina on September 04, 2001 12:28 PM
I have the VB code to do this but don't want to have to paste it in every single worksheet I might be working on. Is there a way to implement this globally ?
The code I have is this:
(general) (declaration)
Dim x As Long
(Worksheet) (SelectionChange)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Set the row containing the active cell to light yellow w/BOLD font
ActiveCell.EntireRow.Interior.Color = RGB(255, 255, 160)
ActiveCell.EntireRow.Font.Bold = True
' Check for first execution of the macro and set row
' value if it is:
If x = Empty Then
x = ActiveCell.Row
' Set previous row property back
ElseIf Not x = ActiveCell.Row Then
Rows(x).EntireRow.Interior.Color = RGB(255, 255, 255)
If x > 1 Then Rows(x).EntireRow.Font.Bold = False
Rows(x).EntireRow.Interior.Pattern = -4142
End If
' Capture new row value for comparison against next selection.
x = ActiveCell.Row
End Sub
=================================
Comments:
Pattern=-4142 puts the gridlines around the active cell
RGB(255,255,255)=White
RGB(255,255,160)=Light Yellow