borgeshugo
New Member
- Joined
- Jul 29, 2014
- Messages
- 5
My idea is to restore the color index of that row before closing the file.
Is missing the code before I close the workbook.
If someone can help please
Thank you
Is missing the code before I close the workbook.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Const cnNUMCOLS As Long = 1056
Const cnHIGHLIGHTCOLOR As Long = 25 'default lt. yellow
Static rOld As Range
Static nColorIndices(1 To cnNUMCOLS) As Long
Dim i As Long
Application.ScreenUpdating = False
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
If nColorIndices(i) = xlNone Then
.Item(i).Interior.ColorIndex = xlNone
Else
.Item(i).Interior.Color = nColorIndices(i)
End If
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.Color
If .Item(i).Interior.ColorIndex = xlNone Then
nColorIndices(i) = xlNone
Else
nColorIndices(i) = .Item(i).Interior.Color
End If
Next i
.Interior.ColorIndex = cnHIGHLIGHTCOLOR
End With
Application.ScreenUpdating = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
??????
End Sub
If someone can help please
Thank you