Highlight active row & column within a defined range (Not a

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi Dennis,

It works fine.
May I suggest that you check if named region "data" exists. I inserted your code, but forgot to name B2:F16 "data" and got an error 1004.
 
Upvote 0
Hi Dennis

Always good to see guys work given away, make me happy ay rate.

There are many versions and ways to do this and i just love to see DIFFERENT ways and ideas

Thank you - i cant say whats best as they are all different this board is littered with examples all that work, i say depends on just what you want.

Jack
 
Upvote 0
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 :smile:

Kind regards,
Dennis
Hi,

For those who can use it,here in another one

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim InRange As Range
Cells.Interior.ColorIndex = xlNone
Set InRange = Application.Intersect(Target, Range("N8:AX25"))
If InRange Is Nothing Then Exit Sub
Range(Cells(Target.Row, 14), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 3
Range(Cells(8, Target.Column), Cells(Target.Row, Target.Column)).Interior.ColorIndex = 3
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top