Hi all! My current code changes cell color to yellow with a single click and then changes it back to nothing when clicked again. I was wondering if I can do that this time changing it to green when double clicked and then back to nothing when double clicked again. Here's my current code:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal target As Range, Cancel As Boolean)
Cancel = True
Worksheet_SelectionChange target
End Sub
Private Sub Worksheet_SelectionChange(ByVal target As Range)If Intersect(target, Range("B9:AF129")) Is Nothing Then Exit Sub
'If the target cell is clear
If target.Interior.ColorIndex = xlNone Then
'Then change the background to the specified color
target.Interior.ColorIndex = 6
'But if the target cell is already the specified color
ElseIf target.Interior.ColorIndex = 6 Then
'Then clear the background color
target.Interior.ColorIndex = xlNone
End If
End Sub
Last edited: