ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Update Macro: Leave Colour As Before Once Cell is Not Active (https://www.excelbanter.com/excel-discussion-misc-queries/69027-update-macro-leave-colour-before-once-cell-not-active.html)

JB2010

Update Macro: Leave Colour As Before Once Cell is Not Active
 
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

JE McGimpsey

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

http://www.mcgimpsey.com/excel/highl...iteRetainColor

In article ,
JB2010 wrote:

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


JB2010

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


cheers


jb

"JE McGimpsey" wrote:

See

http://www.mcgimpsey.com/excel/highl...iteRetainColor

In article ,
JB2010 wrote:

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




All times are GMT +1. The time now is 09:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com