Highlight the Row of the Selected Cell

Add to Favorites

This macro will highlight the row and column of the active cell. This will fill the row of the active cell with a solid background color and remove the color when a different cell is selected within the excel spreadsheet. Anytime you select a different cell, the new column and row will be highlighted. This is a great macro for zeroing in on a specific cell during a presentation or just when working in a really big spreadsheet. Also, if you remove the gridlines from the spreadsheet, it can be hard to determine which row or column a cell is in and this will allow you to figure that out much quicker.

This macro will overwrite any previous color in the selected cell and row. That means that if you have a worksheet with a lot of background colors and you use this macro and start selecting cells, the previous background colors will disappear.

To change the color of the highlight change the number in this line of code .ColorIndex = 6.

Where to install the macro:  Worksheet

Highlight the Row of the Selected Cell

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

Static rr

If rr <> "" Then
 With Rows(rr).Interior
  .ColorIndex = xlNone
 End With
End If r = Selection.Row
rr = r With Rows(r).Interior
 .ColorIndex = 6
 .Pattern = xlSolid
End With End Sub





Similar Content on TeachExcel
Pass Arguments to a Macro Called from a Button or Sheet in Excel
Tutorial: How to pass arguments and values to macros called from worksheets, buttons, and anything e...
Count the Occurrences of the Largest or Smallest Value in a Range
Tutorial: How to count the occurrence of the largest or smallest value in a range; basically, how m...
NPER Function - Calculate Number of Periods Needed for a Set of Payments in Excel
Tutorial: How to calculate the number of periods required for an investment in order to get the desi...
Highlight the Column of the Selected Cell
Macro: This macro will highlight the column of the active cell. This will fill the column of...
Create and Manage Tables in Excel
Tutorial: Here, I'll show you everything you need to know to get started using tables in Excel; how...
How to Create and Manage a Chart in Excel
Tutorial: In this tutorial I am going to introduce you to creating and managing charts in Excel. Bef...



How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.


Similar Content
Pass Arguments to a Macro Called from a Button or Sheet in Excel
Tutorial: How to pass arguments and values to macros called from worksheets, buttons, and anything e...
Count the Occurrences of the Largest or Smallest Value in a Range
Tutorial: How to count the occurrence of the largest or smallest value in a range; basically, how m...
NPER Function - Calculate Number of Periods Needed for a Set of Payments in Excel
Tutorial: How to calculate the number of periods required for an investment in order to get the desi...
Excel Forum