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
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)
Target.Interior.Color = vbRed
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
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:
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 as the below demo shown.
Download and try it now! (30-day free trail)
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.
Before applying Kutools for Excel, please download and install it firstly.
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.
If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps.
Highlight entire row and column of active cell with Kutools for Excel
Best Office Productivity Tools
Supercharge Your Spreadsheets: Experience Efficiency Like Never Before with Kutools for Excel
Kutools for Excel boasts over 300 features, ensuring that what you need is just a click away...
Supports Office/Excel 2007-2021 & newer, including 365 | Available in 44 languages | Enjoy a full-featured 30-day free trial.
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!




























