

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

Press Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window. Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)ģ. VBA: change cell color when clicking on it Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) In the Microsoft Visual Basic for Applications window, please copy and paste the below VBA code into the Code window. 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.Ģ. Here, you can change the background color of a cell when double clicking it or right clicking on it with the following VBA code.ġ. Highlight entire row and column of active cell with Kutools for 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.Ĭhange cell color when cell is clicked with VBA codeĬhange the highlighted color when cells are selected with VBA code How to change cell color when cell is clicked or selected in Excel?
