Highlight row of selected cell in Excel
Highlight Row of Selected Cell
I want to highlight the entire row where a selected cell is. For instance, I select a cell in row 5, I want the entire row to be highlighted. If I then select a cell in Row 8, I want Row 5 to return to normal, and Row 8 to be highlighted.
Answer:
Try the following code in VBA. Press Alt F11.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rowNumberValue As Integer, columnNumberValue As Integer, i As Integer, j
As Integer
Cells.Interior.ColorIndex = 0
rowNumberValue = ActiveCell.Row
columnNumberValue = ActiveCell.Column
For j = 1 To 14
' columnNumberValue
Cells(rowNumberValue, j).Interior.ColorIndex
= 37
Next j
Cells(rowNumberValue, columnNumberValue).Interior.ColorIndex =
24
End Sub
(for formulas, depending on your country, you might have to change ; with , or the opposite