How to Change a Cell Color When Clicked in Excel
Question details
The user wants to toggle a cell's background color between blue and green by clicking on it, specifically for tracking weekly check-ins.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating an interactive weekly check-in tracker where a single click visually marks a task's status via color change.
- Observed behavior
- Requires a mechanism to detect a mouse click on a cell, changing its default blue color to green, and reverting it back to blue on the next click.
Since Excel does not have a built-in cell click toggle feature, you will need to enable the Developer tab to use a simple VBA (Visual Basic for Applications) macro for this solution.
Use VBA to Create a Click-to-Toggle Cell Color Effect
The most effective way to change a cell's color upon clicking is by using a Worksheet SelectionChange event in VBA to detect the click and swap the background colors.
Because simply selecting a cell does not change its underlying value, standard Conditional Formatting cannot detect a click. VBA intercepts the click action and applies the desired background color based on the cell's current color state.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications Editor in Excel.
In the Project Explorer panel on the left, find the specific worksheet where you want the toggle effect (e.g., Sheet1) and double-click it to open the code window.
Select 'Worksheet' from the left dropdown at the top of the code window, and 'SelectionChange' from the right dropdown. Enter VBA code to check the Target.Interior.ColorIndex. Instruct the code to change the color to green (ColorIndex = 4) if it's currently blue (ColorIndex = 5), and vice versa.
Close the VBA Editor and return to your Excel worksheet. Click on a cell within your designated range to see the color automatically switch between blue and green.

Use a Dropdown List with Conditional Formatting (No VBA Alternative)
If you cannot or prefer not to use macros, you can use a simple dropdown list combined with Conditional Formatting to achieve a similar visual tracking effect.
Create Interactive Trackers Easily with WPS Spreadsheet
WPS Spreadsheet fully supports VBA macros, allowing you to implement click-to-toggle color effects and build advanced weekly check-in trackers without any compatibility issues.
- 1. Download and Install: Download WPS Office from the official website and run the lightweight installer on your PC or Mac.
- 2. Open Your Tracker: Launch WPS Spreadsheet and open your existing weekly check-in file.
- 3. Enable Macros and Edit: Navigate to the Developer tab, enable macros, and apply your VBA color toggle code just as you would in Microsoft Excel.

Frequently Asked Questions
Why doesn't standard Conditional Formatting work for cell clicks?
Standard Conditional Formatting is triggered by changes in cell values or formula results, not by user interface actions like mouse clicks or selecting a cell. VBA is required to actively listen for a 'SelectionChange' event.
Will my VBA color toggle macro work on Excel for Web?
No, VBA macros are not supported in the web browser version of Excel. You will need to use the desktop version of Excel or WPS Office to run VBA scripts, or rewrite the automation using Office Scripts for the web environment.
How can I limit the click-to-toggle effect to a specific column?
In your VBA Worksheet_SelectionChange code, you can use the Intersect function (e.g., If Not Intersect(Target, Range("A1:A100")) Is Nothing Then) to ensure the color change only executes when cells within that specific tracker range are clicked.
What is the Excel Focus Cell feature mentioned as an alternative?
Excel's Focus Cell feature is an accessibility and readability tool that visually highlights the currently selected row and column. While helpful for navigating large datasets, it does not apply a permanent color fill to the cell like a tracker requires.




