Dear all,
My intent to colour the excel cell with single mouse click within a range. I use the code below,
But the problem i'm facing is, if the cell turns from "white" to "green", it wont go back to "white" after immediate click. I want to toggle the colours on every single click.
Right now, after one single click it turns to "Green".If you click on this green cell immediately, it wont turn back to "white" (To achieve white colour we must click on some other cell and then click back on present cell)
Could anyone please suggest what is that i'm doing wrong here..?
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "E40:E49"
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Selection.Interior.Color = 16777215 Then
Selection.Interior.Color = 65280
Else
Selection.Interior.Color = 16777215
End If
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
Bookmarks