VBA Color Changing Cell with multiple clicks

Inquiring_Minds

New Member
Joined
Jan 5, 2023
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
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.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You could assign it to a keypress, in the following example is for delete key.

VBA Code:
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:

VBA Code:
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.
 
Upvote 0
How about this one:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Target.Interior.ColorIndex = xlNone
End Sub
 
Upvote 0
Solution
How about this one:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Target.Interior.ColorIndex = xlNone
End Sub
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
 
Upvote 0
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.
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.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top