When right clicking within cell range A1 : D4, cell turns green.
I want to expand further on this and add that when right clicking on green cell, cell turns yellow. And when right clicking on yellow, cell turns white.
How would that look like?
And is there a cleaner way by not using Elseif (like switch?)
I want to expand further on this and add that when right clicking on green cell, cell turns yellow. And when right clicking on yellow, cell turns white.
How would that look like?
And is there a cleaner way by not using Elseif (like switch?)
Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Dim rInt As Range
Dim rCell As Range
Set rInt = Intersect(Target, Range("A1:D4"))
If Not rInt Is Nothing And Target.Interior.ColorIndex = 0 Then
For Each rCell In rInt
Next
End If
Set rInt = Nothing
Set rCell = Nothing
Cancel = True
Target.Interior.ColorIndex = 4
End Sub