ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlighting the active row (https://www.excelbanter.com/excel-programming/318719-highlighting-active-row.html)

Daniel Bonallack

Highlighting the active row
 
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


Don Guillett[_4_]

Highlighting the active row
 
Have a look in the ThisWorkbook module & put the code within the
Private Sub Workbook_SheetSelectionChange(
--
Don Guillett
SalesAid Software

"Daniel Bonallack" wrote in
message ...
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





All times are GMT +1. The time now is 06:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com