Estou a fazer um código mas como ainda sou muito verde no VBA não sei meter isto a funcionar. É muito simples, eu quero carregar numa celula e ela vai alterar um boolean entre True e False.
Eu quando carrego ele mete VERDADEIRO, mas depois se carregar lá outra vez, ou sair da celula e voltar a seleccionar ele não muda para 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
Há alguma maneira mais fácil ou viável de fazer isto e funcionar?
mudancasAtivas
, ela não está definida, portanto ela não vai entrar noIf
..