Thank you for sharing that, it works perfectly and is much more advanced than
my code so it will help to increase my understanding.
Many thanks,
Martin
"JBeaucaire" wrote:
>
> This is the code I use in my sheets to do what you're talking about, it
> always keeps the current row highlighted all the way across the screen.
> Works great for me.
>
> Code:
> --------------------
> Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
> Const cnNUMCOLS As Long = 100
> 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
> --------------------
>
> This code would go into the worksheet tab.
>
>
> --
> JBeaucaire
> ------------------------------------------------------------------------
> JBeaucaire's Profile: http://www.thecodecage.com/forumz/member.php?userid=73
> View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=45419
>
>