Change colour of cell while selected

‘Add this to the worksheet General Declarations

Dim rBefore As Range

‘ Here is the macro that is based on an event

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

‘ This macro changes the colour of the highlighted cell while it is selected.

 If Not rBefore Is Nothing Then
        rBefore.Interior.ColorIndex = xlAutomatic
    End If
    Target.Interior.ColorIndex = 3
    Set rBefore = Target
End Sub

Sub

Leave a Reply