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.


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

 Other excel answers



You can find similar Excel Questions and Answer hereunder

1) How can I avoid updates to cell values during macro execution?

2) How can I ensure that user enters only certain acceptable values in an input cell?

3) How can I identify the cells that influence a particular cell to help with debugging of my spreadSheet or understand a spreadSheet that I inherited?

4) How can I activate a routine when there is a change in value of a cell?

5) How can I enter a picture in a cell?

6) How can I get input from user through a prompt and assign user's input to a cell?

7) How to find the column number from the cell address in VBA

8) Remove the apostrophe cell text values in Excel

9) How can I add and link a Chart Title to a cell value?

10) How can I enter a text in a cell with subscript and superscript?


Here the previous and next chapter