How change highlight cell in excel with VBA?

Dsp 1024 51 Reputation points
2021-09-30T20:26:06.633+00:00

Hi all,
I wanted to highlight the whole row where the cursor is in Excel and I found (below) code that works fine. But it also resets the fill color (to 0) if any of the cells had any fill. Is there a way to avoid that? Also, can I have the actual cell that the cursor is on with a different color? Thanks.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Target.EntireRow.Interior.ColorIndex = 4
End Sub
0 comments No comments
{count} votes