# VBA Color Changing Cell with multiple clicks



## Inquiring_Minds (Jan 5, 2023)

I am using the below for the red/green clicks on cell, but I want to add another click to have the original no fill color show... or if there is a way that I can revert the clicked cells to the original color? I'm not sure if my question makes sense.

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

I'm creating a checklist/spreadsheet for multiple users and do not want to have wording in the cell, just colors.


----------



## bferraz (Jan 5, 2023)

You could assign it to a keypress, in the following example is for delete key.


```
Private Sub Worksheet_Activate()
    Application.OnKey Key:="{DEL}", Procedure:="NoFilling"
    End Sub
Private Sub Worksheet_Deactivate()
    Application.OnKey Key:="{DEL}"
End Sub
```

Note that you need to add the following procedure to a standard module:


```
Sub NoFilling()

Selection.Interior.Color = xlNone

End Sub
```

In this specific case, since you just need colors, using delete key won't be a problem because hooking makes it not deleting the values from the cells on this worksheet.


----------



## Flashbond (Jan 5, 2023)

How about this one:

```
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Target.Interior.ColorIndex = xlNone
End Sub
```


----------



## Inquiring_Minds (Jan 5, 2023)

Flashbond said:


> How about this one:
> 
> ```
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> ...


This is working somewhat.  I edited the code to show below, but it's wanting me to save it as a macro and then I have to click on each individual cell for it to go as No Fill.  This wouldn't be a problem for people who are familiar with excel, but I am working with people who are not excel friendly (yes attempt at humor... sadly).  Is there a way that would be easier, or no?  

Sub NoFilling()
    Selection.Interior.Color = xlNone
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Target.Interior.Color = vbGreen
End Sub
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    Target.Interior.Color = vbRed
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Target.Interior.ColorIndex = xlNone
End Sub


----------



## Inquiring_Minds (Jan 5, 2023)

Inquiring_Minds said:


> I am using the below for the red/green clicks on cell, but I want to add another click to have the original no fill color show... or if there is a way that I can revert the clicked cells to the original color? I'm not sure if my question makes sense.
> 
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
> Target.Interior.Color = vbGreen
> ...


Let me add that there are some cells that are set with a color that I do NOT want to change (because they have formulas and I don't want people to edit them.


----------

