About Me
Com tecnologia do Blogger.
Seguidores
Estatisticas
2005-08-16
Se pretendermos que o utilizador digite, por exemplo, na célula "A1", valores que não sejam negativos ou zero, como no exemplo:


podemos socorrer-nos de um pouco de VBA.
O Código:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If IsEmpty(Range("A1")) Then
Exit Sub
End If
If Range("A1") < 0 Then
MsgBox "O valor não pode ser negativo! Tente outra vez!!!"
Range("A1").ClearContents
ElseIf Range("A1") = 0 Then
MsgBox "O valor não pode ser zero! Tente outra vez!!!"
Range("A1").ClearContents
Else
Exit Sub
End If
End Sub
podemos socorrer-nos de um pouco de VBA.
O Código:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If IsEmpty(Range("A1")) Then
Exit Sub
End If
If Range("A1") < 0 Then
MsgBox "O valor não pode ser negativo! Tente outra vez!!!"
Range("A1").ClearContents
ElseIf Range("A1") = 0 Then
MsgBox "O valor não pode ser zero! Tente outra vez!!!"
Range("A1").ClearContents
Else
Exit Sub
End If
End Sub