hi,
I have a macro to highlight the active row of the highlighted cell, but there is one problem. When I save and reopen the workbook, the last row that was highlighted when saved remains permanently highlighted. So if I do this 10 times, I will have 10 rows permanently highlighted.
the code is as under:
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
So for example if I last click on cell E25, entire row 25 gets highlighted, and when I save and reopen, row 25 remains highlighted no matter what I do.. It cannot be altered!!!
I need a way to ensure that when I save and reopen, the active cell does not remain permanently highlighted. Thanks in advance!!![]()
Bookmarks