Highlight Row & Column of Selected Cell using VBA

Share

Facebook
Twitter
LinkedIn

When looking at a big table of analysis (or data), it would make our life simpler if the selected cell’s column and row are highlighted, so that we can instantly compare and get a sense of things. Like this:

How to Highlight row & column of a selected cell using Excel & VBA

 

Who doesn’t like a little highlighting. So lets learn how to do highlighting today.

Step 1: Identify the area for highlighting

This is simple, unless you are AUI (analyzing under influence). Lets assume that we are dealing with a range of cells in B4:I14

Step 2: Use 2 cells to capture the selected row & column details

Outside our highlight range, lets set aside 2 cells (E17 & E18 in this case) for keeping the details of which row & column needs to be highlighted.

We can call these cells selRow & selCol.

Step 3: Unleash the VBA magic

  • Right click on the sheet name & choose ‘view code’.
  • Choose Worksheet & Selection Change from the drop-downs.
  • Excel would add a blank Worksheet_SelectionChange() sub
  • Write the below lines of code.
    • [selRow] = Target.Row
    • [selCol] = Target.Column
  • Done. So much simpler than using floo network or transmogrifying muggles.

VBA code to capture selected cell's row & column

Step 4: Add conditional formatting to highlight selected cell’s row & column

Now that we know which row & column should be highlighted, it is a simple matter of switching on Excel’s highlighting charm – Conditional Formatting.
Conditional formatting rules to highlight row & column of a selected cell
Select the entire range (B4:I14) and go to conditional formatting > new rule

Select the rule type as Use a formula… and use a below rules.

  • =ROW(B4) = selRow
  • Apply formatting
  • Repeat the steps & this time use the rule =COLUMN(B4) = selCol

Step 5: Show off.

Incorporate this technique in to your dashboard or weekly report. Watch the socks knocked off your boss’. Bask in the glory. Repeat and enjoy.

Bonus Tip: Use similar technique to enhance user inputs

You can use similar idea to conditionally show messages on your worksheets. See this demo.

Enhance user inputs with message display in Excel - demo

I am not telling you how to do this. But I know you are awesome enough to figure this out.

Download Example File

Click here to download example file & understand how to use this technique.

Do you use highlighting techniques in your reports & analysis?

I always use conditional formatting & light-weight VBA to enhance my dashboards and analysis. Especially conditional formatting is almost a magical way to make stunning reports & show off things that are important.

What about you? Do you use these techniques often? what is your experience like? Please share your tips & ideas using comments. I am all ears.

Transmogrify your boring work to awesome – Check out!

Also see introduction to conditional formatting & VBA to understand to get the basics right.

For more potent magic, please consider joining our Online VBA Classes.  You are going to leave everyone spellbound.

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

11 Responses to “FREE Calendar & Planner Excel Template for 2025”

  1. Md says:

    Hi,
    I downloaded this 2025 Calendar template. I checked the custom tab. Is it possible to change the weekend Fri & Sat.

    Thanks

  2. Nitesh says:

    Activities of some dates are not getting displayed on "Any month" and "printable calendar" sheets.
    e.g. Activity of 24 Apr 25.

  3. Kristin Finn says:

    Love this calendar... I have highlight planner dates enabled but all dates are blue, is it possible to customize the color based on the type assigned to each date?

  4. Peter says:

    What would be the right way to add more Holidays in the Customizations?

    Inserting rows in the Holiday List causes the blank cells in the calendar to turn Blue.

  5. Gabe says:

    This is amazing!!! The best I've seen so far!! Is it possible to update it to consider a column for the final date? That way, if an event lasts more than one day, it repeats in the calendar

  6. Kalaignan says:

    How do we change/insert the customization "Icon Options" ?

  7. Jackie William says:

    Is there anyway this can turn into an academic calendar (ie. start month is July and runs all the way through June of next year)?

  8. Rebecca says:

    Is there a way to make it something that is more than a day without having to add it to every day of that week.

Leave a Reply