To have an entire row highlighted to some color if any cell in that row is selec

N

Nick

Can someone help me please? I'm trying to find a way to
have an entire row highlight to some color if any cell in
that row is selected.
I have the following information (not sure if it is
correct), but I have no idea how to use it. Is it a macro?
visual basic? Help!

Private Sub Worksheet_SelectionChange(By Val Target As
Excel.Range)
Static oldRange as Range
Static colorIndices(256) As Integer
Dim i As Integer
If Not oldRange Is Nothing Then 'Restore color indices
For i=1 to 256
Cells(oldRange.row,
i).Interior.ColorIndex=colorIndices(i)
Next i
End If
For i = 1 to UBound(colorIndices)
colorIndices(i)=Cells(ActiveCell.row,i).Interior.ColorIndex
Next i
ActiveCell.EntireRow.Interior.ColorIndex=15
Set oldRange=ActiveCell.EntireRow
End Sub

Thank you!
 
B

Bob Phillips

Nick,

It's worksheet event code, so it goes into the worksheet code module. To get
at this, right-click on the sheet name tab, select View Code from the menu,
and then paste the code into the code pane that pops up.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top