Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Carolina Lopez   on Sep 20 In MS Office Category.

  
Question Answered By: Jay Richards   on Sep 20

This does it:
Delete the following lines from the current code:

Const cnNUMCOLS As Long = 256
Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow
Static rOld As Range
Static nColorIndices(1 To cnNUMCOLS) As Long

Insert the following lines in the declaration area of a standard
module:
Public Const cnNUMCOLS As Long = 256
Public nColorIndices(1 To cnNUMCOLS) As Long
Public Const cnHIGHLIGHTCOLOR As Long = 36 'default lt. yellow
Public rOld As Range


Add the following code  to the ThisWorkbook code module:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim i As Long
With rOld.Cells
For i = 1 To cnNUMCOLS
.Item(i).Interior.ColorIndex = nColorIndices(i)
Next i
End With
End Sub

That's it.

The only thing that's required is to select a different row  from the
active cell to restart the row highlighting but this could be
corrected by commenting out or deleting the line:

If .Row = ActiveCell.Row Then Exit Sub 'same row, don't restore

but would add to row flicker if moving left and right in the same row.

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Highlight a row without losing background colors Or get search suggestion and latest updates.


Tagged: