How To Highlight Row And Column Of Selected Cell Using VBA In Microsoft Excel 2010

In this article, you will learn how to highlight row & column of selected cell.


Click on Developer tab

From Code group, select Visual Basic
Or press ALT + F11 shortcut key for opening VB Editor.

Enter the following code in the current sheet

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

Static xRow

Static xColumn

    If xColumn<> "" Then

    With Columns(xColumn).Interior

    .ColorIndex = xlNone

    End With

    With Rows(xRow).Interior

    .ColorIndex = xlNone

    End With

    End If

pRow = Selection.Row

pColumn = Selection.Column

xRow = pRow

xColumn = pColumn


With Columns(pColumn).Interior

.ColorIndex = 6

.Pattern = xlSolid

End With


With Rows(pRow).Interior

.ColorIndex = 6

.Pattern = xlSolid

End With

End Sub
If we select cell C3 then, row number 3 & column C will get highlighted. Refer below shown snapshot:
As we change the cell, the row & column number will get highlighted accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Youtube