Update Macro: Leave Colour As Before Once Cell is Not Active

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there


i got this Macro code, which makes the Active cell change colour, but the
problem is that once you move away from that cell it leaves that cell with no
colour. I need it to return the colour the cell was before it became active.

What would i do to this code:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Static OldCell As Range
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
End If
Target.Interior.ColorIndex = 8
Set OldCell = Target
End Sub


Any help gratefully received


cheers

jb
 
Back
Top