Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to change cell color when cell is clicked or selected in Excel?

This article will show you some methods of how to change cell color while clicking on a cell, and change the highlighted color while selecting a range of cells in Excel.

Change cell color when cell is clicked with VBA code

Change the highlighted color when cells are selected with VBA code

Highlight entire row and column of active cell with Kutools for Excel


One click to highlight row and column of selected cell in Excel:

Kutools for Excel's Reading Layout utility helps you quickly highlight row and column of selected cell in Excel. See screenshot: Download the full feature 60-day free trail of Kutools for Excel now!

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download the free trial Now!

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial


Change cell color when cell is clicked with VBA code

Here, you can change the background color of a cell when double clicking it or right clicking on it with the following VBA code.

1. In the worksheet you will change the cell color when clicking on it, right click the sheet tab and click View Code from the right-clicking menu.

2. In the Microsoft Visual Basic for Applications window, please copy and paste the below VBA code into the Code window.

VBA: change cell color when clicking on it

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Target.Interior.Color = vbRed
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Cancel = True
    Target.Interior.Color = vbGreen
End Sub

3. Press Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window.

Then, when you double click a cell, it will be colored in red. And when you right click on a cell, it will be colored in green. See screenshot:


Change the highlighted color when cells are selected with VBA code

By default, when selecting a range of cells, the highlighted color is gray. If you want to make the selected range more standing out, you can change its highlighted color to the one you need. Please do as follows.

1. Right click the sheet tab you want to change the highlighted color of the selected range, and click View Code from the right-clicking menu.

2. In the Microsoft Visual Basic for Applications window, please copy and paste the below VBA code into the Code window.

VBA code: change the highlighted color of selected range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With Target
        .Worksheet.Cells.FormatConditions.Delete
        .FormatConditions.Add xlExpression, , "TRUE"
        .FormatConditions(1).Interior.Color = vbYellow
    End With
End Sub

3. Press Alt + Q keys at the same time to close the Microsoft Visual Basic for Applications window.

From now on, the highlighted color of selected range or cell is changed to yellow. When you click another cell or range of cells, the cells will be colored automatically.


Highlight entire row and column of active cell with Kutools for Excel

If you are dealing with a large worksheet, it is necessary to highlight the entire row and column of the active cell in order to make reading more easily. Here the Reading Layout utility of Kutools for Excel can help you.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

1. Click Kutools > Reading Layout. See screenshot:

Then the reading layout is enabled, you can see the row and column of active cell are highlighted immediately.

Note: You can change the reading layout settings based on your needs as below screenshot shown.

Tip.If you want to have a free trial of this utility, please go to download the software freely first, and then go to apply the operation according above steps.


Office Tab - Tabbed Browsing, Editing, and Managing of Workbooks in Excel:

Office Tab brings the tabbed interface as seen in web browsers such as Google Chrome, Internet Explorer new versions and Firefox to Microsoft Excel. It will be a time-saving tool and irreplaceble in your work. See below demo:

Click for free trial of Office Tab!

Office Tab for Excel


Highlight entire row and column of active cell with Kutools for Excel

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial now!


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  • Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  • Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  • No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  • Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    rahayu · 1 months ago
    trimakasih
  • To post as a guest, your comment is unpublished.
    rahayu · 1 months ago
    td muncul=tidak muncul
  • To post as a guest, your comment is unpublished.
    rahayu · 1 months ago
    Salam...
    sy sudah install kutools, tp kok td muncul tab kutools di layar excel ya? gmn cara mmunculkannya?trimakasih
  • To post as a guest, your comment is unpublished.
    Cr Decima · 2 months ago
    I have a problem.
    I want change color of one hyperlink if it had linked with one PDF to RED and if had not link with one PDF will show BLUE color.
    How can I do now?
    • To post as a guest, your comment is unpublished.
      crystal · 2 months ago
      Good day,
      Sorry can't help you with that. Thanks for commenting.
  • To post as a guest, your comment is unpublished.
    Devika Kalika · 4 months ago
    I tried the "Change the highlighted color when cells are selected with VBA code" option and saved my excel as Macro Enabled Worksheet. Now the last cells that were selected are highlighted and won't highlight other cells when selected. I've deleted code and reentered and saved, but still no change. I can't remove the previous highlight either. I'm at lost on what to do.
    • To post as a guest, your comment is unpublished.
      crystal · 3 months ago
      Hi,
      The code works well in my case after saving the workbook as an Excel Macro-Enabled Workbook.
      Can you tell me your Excel version?