Highlight the Row and Column of the Selected Cell

Add to Favorites
Author:

This macro will highlight the row and column of the active cell. This will fill the column and 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, column, 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 and Column of the Selected/Active Cell

Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

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





Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons 50+ Hours of Instruction 200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Similar Content on TeachExcel
Input Form to Get Data and Store it in Another Tab in Excel
Tutorial: How to make a user input form in Excel and have the data stored on another worksheet at th...
Put Data into a UserForm
Tutorial: How to take data from Excel and put it into a UserForm. This is useful when you use a form...
Best Lookup Formula in Excel - Index and Match
Tutorial: A lookup using INDEX and MATCH is like a VLOOKUP without the restrictions.  Index and Ma...
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...
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...
Create an Index / Table of Contents worksheet
: To create an Index / Table of Contents worksheet to a workbook: 1) Add a new worksheet and...


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.

Tutorial Details
Similar Content
Input Form to Get Data and Store it in Another Tab in Excel
Tutorial: How to make a user input form in Excel and have the data stored on another worksheet at th...
Put Data into a UserForm
Tutorial: How to take data from Excel and put it into a UserForm. This is useful when you use a form...
Best Lookup Formula in Excel - Index and Match
Tutorial: A lookup using INDEX and MATCH is like a VLOOKUP without the restrictions.  Index and Ma...
Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course