I am making a code but as I am still very green in VBA I do not know how to get this working. It's very simple, I want to load a cell and it will change a boolean between True and False.
When I load it, it gets TRUE, but after pressing it again, or leaving the cell and selecting it again, it does not change to false!
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Dim mudancasAtivas As Boolean
If Not Intersect(Target, Range("E1:E1")) Is Nothing Then
With Target(1, 3)
If mudancasAtivas = True Then
mudancasAtivas = False
.value = mudancasAtivas
ElseIf mudancasAtivas = False Then
mudancasAtivas = True
.value = mudancasAtivas
End If
End With
End If
If Not Intersect(Target, Range("E2:E10000")) Is Nothing Then
If mudancasAtivas = True Then
Codexxx
End If
End If
End If
End Sub
Is there any easier or feasible way to do this and work?