Change Colour Of Cell When Entering Data

‘This macro requires a variable to be set, and will run on every change to the worksheet.

Dim rBefore As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not rBefore Is Nothing Then
rBefore.Interior.ColorIndex = xlAutomatic
End If
Target.Interior.ColorIndex = 3
Set rBefore = Target
End Sub