On 2002-09-22 06:28, XL-Dennis wrote:
Hi Board,
From time to time I see queries about highlightning active row and column.
In general I like this approach because it´s support the users, especially when working with larger data-tables etc.
However, most of the answers shows how to highlight the whole active row as well as the whole column.
The procedure below shows a way to only highlight active row & column within a defined range.
<PRE>
<FONT color=blue>Private <FONT color=blue>Sub </FONT></FONT>Worksheet_SelectionChange(<FONT color=blue>ByVal</FONT> Target<FONT color=blue> As</FONT> Range)
<FONT color=#ff0000>'Purpose: Highlight the active row and column within a limit range.
</FONT>
<FONT color=#ff0000>'Place this procedure into a sheet-module.
</FONT>
<FONT color=#ff0000>'The name Data refer to the range: B2:F16
</FONT>
<FONT color=blue>Set </FONT>Target = Range("Data")
<FONT color=#ff0000>'Reset the rangecolour to no colour.
</FONT>
Target.Interior.ColorIndex = -4142
<FONT color=#ff0000>'No action taken unless the active cell address is within the defined range.
</FONT>
<FONT color=blue>If </FONT>Intersect(Target, ActiveCell) Is<FONT color=blue> Nothing</FONT><FONT color=blue> Then </FONT><FONT color=blue>Exit Sub</FONT>
<FONT color=#ff0000>'Add color to the row from the active cell to the B-column.
</FONT>
Range(Cells(ActiveCell.Row, "B"), Cells(ActiveCell.Row, _
ActiveCell.Column)).Interior.ColorIndex = 40
<FONT color=#ff0000>'Add color to the column from the active cell to row 2.
</FONT>
Range(Cells(ActiveCell.Row, ActiveCell.Column), Cells(2, _
ActiveCell.Column)).Interior.ColorIndex = 40
<FONT color=blue>End Sub</FONT>
</PRE>
I don´t claim that this is a uniqueor a smart solution just only a practical solution to support users.
All comments are welcome
Kind regards,
Dennis