Excel Macro code to Highlight the Active Row and Column

How to Highlight the Active Row and Column in excel sheet through VBA Macro Code

For using this VBA macro code in excel to Highlight the Active Row and Column you will have copy below Macro code in Excel Visual Basic Editor
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim strRange As String
strRange = Target.Cells.Address & "," & _
Target.Cells.EntireColumn.Address & "," & _
End Sub

This very useful macro code whenever you want to analyze a data table. You can Highlight the Active Row and Column. Here are the quick steps to apply this code.

  1. Open VBE (ALT + F11).
  2. Go to Project Explorer (Ctrl + R, If hidden).
  3. Select your workbook & double click on the name of a particular worksheet in which you want to activate the macro.
  4. Paste the code into it and select the “BeforeDoubleClick” from event drop down menu.
  5. Close VBE and you are done.

Remember that, by applying this macro you will not able to edit the cell by double click.

What is a Macro Code?

In MS Excel, macro code is a programming code which is written in VBA (Visual Basic for Applications) language.

The idea is to use macro code for automating various activities which you perform manually in Excel, otherwise.

For example, you can use a code to print only a particular range of cells just with a single click instead of selecting the range -> File Tab -> Print -> Print Select -> OK Button.

How to use a Macro Code in Excel


  • On the left side in “Project Window”, right click on the name of your workbook and insert a new module.



  • Just paste your code into the module and close it.



  • Now, go to your developer tab and click on the macro button.


  • It will show you a window with a list of the macros you have in your file from where you can run a macro from that list.





Monthly Business Budget

A monthly business budget provides a precise image of expenses and revenues and gave drive to important business decisions. Whether …

Download Now

Cash Flow Forecast

A cash flow forecast or cash flow projection is like a budget, but rather than computing revenues and expenses, it …

Download Now

Income Statement

Download Income Statement Excel Template to monitor your incomes sources The income statement displays information on the economical results of …

Download Now

Small Business Profit and loss Statement

Download Best Profit and Loss Statement in Excel for small business A profit and loss statement for small business —also …

Download Now

Yearly Profit and Loss Statement

The short term prediction is not a necessary part of a basic business plan. So, the yearly Profit and Loss …

Download Now

Profit and Loss Projection

A profit and loss, or P&L, is a projection of how much money you make by selling services or how …

Download Now