Highlighting the active row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Bob Philips provided the code below in answer to someone's question. It
highlights the line of the active cell. This is SO useful to my team, that I
want to be able to add it to any worksheet we use.

1. Is there a way to make a macro that adds code (the code below) to the
active worksheet? (I would then make an addin for the group that copies in
the below)

2. If not, can the below be applied easily to every sheet in a workbook?

3. If I wanted this to be part of the default workbook (Excel XP), how
would I do this? Would it then be present on every sheet added?

Daniel
(PS, thanks Bob)

_________________________________

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireRow
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
With .FormatConditions(1)
With .Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
With .Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 5
End With
End With
.FormatConditions(1).Interior.ColorIndex = 20
End With

End Sub
 
Have a look in the ThisWorkbook module & put the code within the
Private Sub Workbook_SheetSelectionChange(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top