Highlighting entire row and not just cell where cursor is placed

N

Nick

I have a large amount of data and was wondering if there
was a way that the entire row would highlight vs just the
cell that the cursor is in.
For instance, I want the entire row of line 1115 to be
highlighted (i.e. to stand out) as opposed to just the
cell being highlighted. And, then, if I move to the next
row, the entire row would be highltighted instead of just
the cell my cursor is in.

Thank you for any help.
 
O

Otto Moehrbach

Nick
Here is a write-up I have on what you want to do. HTH Otto
To have an entire row highlighted to some color if any cell in that
row is selected. Note that
the first procedure wipes out all other cell colors on the sheet, not
just that of the last row
selected.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = False
With ActiveCell
.EntireRow.Interior.ColorIndex = 34
End With
End Sub

Another Way Is:
This by J.E.McGimpsey works very good. It preserves any other
colors you may have on the sheet. Change the colorindex to suit.

Private Sub Worksheet_SelectionChange(ByVal 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

If you want both the row and the column highlighted when a cell is
selected:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Rows.Interior.ColorIndex = xlNone
Columns.Interior.ColorIndex = xlNone
ActiveCell.EntireColumn.Interior.ColorIndex = 6
ActiveCell.EntireRow.Interior.ColorIndex = 6
End Sub
 

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