N
Naceur
Hi every one,
I have found this VBA code in McGimpsey & Associates side. It work very
well but the only problem is that went we close the workbook and we open
it later the last selected row before closing during the last time
remained in highlight color.
My idea is to restore the color index of that row before closing the
file.
How can I do this??
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Const cnNUMCOLS As Long = 256
Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow
Static rOld As Range
Static nColorIndices(1 To cnNUMCOLS) As Long
Dim i As Long
If Not rOld Is Nothing Then 'Restore color indices
With rOld.Cells
If .Row = ActiveCell.Row Then Exit Sub 'same row, don't
restore
For i = 1 To cnNUMCOLS
..Item(i).Interior.ColorIndex = nColorIndices(i)
Next i
End With
End If
Set rOld = Cells(ActiveCell.Row, 1).Resize(1, cnNUMCOLS)
With rOld
For i = 1 To cnNUMCOLS
nColorIndices(i) = .Item(i).Interior.ColorIndex
Next i
..Interior.ColorIndex = cnHIGHLIGHTCOLOR
End With
End Sub
Thank you and Best Regards
I have found this VBA code in McGimpsey & Associates side. It work very
well but the only problem is that went we close the workbook and we open
it later the last selected row before closing during the last time
remained in highlight color.
My idea is to restore the color index of that row before closing the
file.
How can I do this??
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Const cnNUMCOLS As Long = 256
Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow
Static rOld As Range
Static nColorIndices(1 To cnNUMCOLS) As Long
Dim i As Long
If Not rOld Is Nothing Then 'Restore color indices
With rOld.Cells
If .Row = ActiveCell.Row Then Exit Sub 'same row, don't
restore
For i = 1 To cnNUMCOLS
..Item(i).Interior.ColorIndex = nColorIndices(i)
Next i
End With
End If
Set rOld = Cells(ActiveCell.Row, 1).Resize(1, cnNUMCOLS)
With rOld
For i = 1 To cnNUMCOLS
nColorIndices(i) = .Item(i).Interior.ColorIndex
Next i
..Interior.ColorIndex = cnHIGHLIGHTCOLOR
End With
End Sub
Thank you and Best Regards