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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top