Highlight entire row when cell selected or being edited

dim4x4

Board Regular
Joined
May 8, 2002
Messages
108
Hello!

I want to have an entire row highlighted when I select or edit a cell in that row. Then when I select or edit a cell in a different row, I want initial row "unhighlighted" (i.e. returned to previous state), and the new row highlighted. Basically, I want to see which row I am working on right now.

Thank you!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi,

Check below code:

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ActiveSheet.Range("1:200").Interior.Color = vbWhite
    Target.EntireRow.Interior.Color = vbYellow

End Sub
 
Upvote 0
Hi Saurabhj!

Thank you for the code! It kind of does what I want to do. However, it removes all other highlighting in the sheet and makes it white. I don't want to do that. I want to have the selected row in yellow, but as soon as I select another row, I want that previous row to go back to its previous highlighting. It may have some cells green, some cells light blue, etc., I want to revert to that as soon as I deselect that row. Also, is it possible to have a macro that turns on this feature. And a macro that turns it off?

Thank you!
 
Upvote 0
check this out
 
Upvote 0
Hi AC PORTA VIA!

Works great, but it changes only a cell highlight. How can I do it for the row?

Thank you!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Dear Fluff!

One more question. How do I make a macro which turns on highlighting rows, and a macro that turns it off?

Thank you again for your help!
 
Upvote 0
You can't not really. Whilst you can disable the selection event the CF will still trigger if you make any changes to the sheet.
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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