question

Dsp1024-8471 avatar image
0 Votes"
Dsp1024-8471 asked Dsp1024-8471 edited

How change highlight cell in excel with VBA?

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


office-vba-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers