row/column highlight

jammoca

Banned
Joined
Nov 6, 2002
Messages
1,100
When I click on a cell, is there a way to have the cells in the column and row that intersect with that cell highlighted or greyed-out automatically .. to highlight the intersection itself ??
 
You were dead-set right ...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect "ana"
Cells.Interior.ColorIndex = xlNone
Rows(Target.Row).Interior.ColorIndex = 3
Columns(Target.Column).Interior.ColorIndex = 4
ActiveSheet.Protect
End Sub

works a treat now many many thanks
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Ok here's what Im now using :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Cells.Interior.ColorIndex = xlNone
Rows(Target.Row).Interior.ColorIndex = 3
Columns(Target.Column).Interior.ColorIndex = 4

End Sub

However, it's removing any cell-shading that I had on the sheet already, and not returning it.

Is there some addition to the code that will allow me to highlight the intersection of row and column, but NOT kill off any pre-existing cell shading ??
 
Upvote 0
Forget that last reply by me, I got my code wrong ... this is how the reply should have read ....

Ok here's what Im now using :

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Cells.Interior.ColorIndex = xlNone
Rows(Target.Row).Interior.ColorIndex = 3
Columns(Target.Column).Interior.ColorIndex = 4

End Sub

However, it's removing any cell-shading that I had on the sheet already, and not returning it.

Is there some addition to the code that will allow me to highlight the intersection of row and column, but NOT kill off any pre-existing cell shading ??
 
Upvote 0
Love this code. So simple. :)

I've modified it so that it only highlights the row. Unfortunately it also removes the existing highlighting from my header cells. Any way to stop this?

Steve
 
Upvote 0
this is working goood but when i close the excel and open it then this code was not working . ple tell me when i open the excel file work th code .
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
Union(Target.EntireRow, Target.EntireColumn).Select
Intersect(Target.EntireRow, Target.EntireColumn).Activate
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,802
Messages
6,181,054
Members
453,014
Latest member
Chris258

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