jim may
Well-known Member
- Joined
- Jul 4, 2004
- Messages
- 7,486
I have the following Macro that is working fine, EXCEPT if I select a cell that has PREVIOUSLY been color-formatted manually - the
below Macro NULLIFIES - meaning it resets my previously colored cell's format is set to "ColorIndex" of None. I need for the below
Macro (to be modified) so as to test if the currently selected cell "ALREADY HAS A COLORINDEX APPLIED", and if so, RESTORE this
Formatting AFTER MOVING AWAY from the cell. Can anyone help me with this modification, please...
Thanks in Advance..
Jim
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Static OldCell As Range
If bFlag = True Then
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
'OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
'OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End If
End Sub
below Macro NULLIFIES - meaning it resets my previously colored cell's format is set to "ColorIndex" of None. I need for the below
Macro (to be modified) so as to test if the currently selected cell "ALREADY HAS A COLORINDEX APPLIED", and if so, RESTORE this
Formatting AFTER MOVING AWAY from the cell. Can anyone help me with this modification, please...
Thanks in Advance..
Jim
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Static OldCell As Range
If bFlag = True Then
If Application.CutCopyMode = 0 Then
If Not OldCell Is Nothing Then
OldCell.Interior.ColorIndex = xlColorIndexNone
'OldCell.Borders.LineStyle = xlLineStyleNone
End If
Set OldCell = Target
OldCell.Interior.ColorIndex = 6
'OldCell.Borders.LineStyle = xlContinuous
Else
If OldCell Is Nothing Then
Set OldCell = Target
Else
Set OldCell = Union(OldCell, Target)
End If
End If
End If
End Sub