Changing cell colour on entry & exit


Posted by Mark Lees on November 13, 2000 12:34 AM

Hi! can anyone help with this?

I want to change the colour of a specific cell when the user selects the cell, which I can do thus:

*********code start*******
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$C$8" Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End If
End Sub
********code ends*******

However, I want the cell to revert to it's original colour on deselecting the cell....can this be done? (forgive me if this is a stupid question, but I did all my VBA programming in Access.....in which I'd use the on enter & on exit properties, but I can't find an equivalent in Excel)

Thanks for your help,

Mark

Posted by Celia on November 13, 2000 1:31 AM

Mark

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address = "$C$8" Then
With Selection.Interior
.ColorIndex = 3
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
Else
Range("C8").Interior.ColorIndex=0
End If
End Sub

Celia



Posted by Mark Lees on November 13, 2000 2:09 AM

Thanks Celia!

Your help was greatly appreciated!

Mark