Olá pessoal, Tudo bem resolvi postar aqui pois é o mesmo problema do @hudsonsaldanha, achei desnecessário abrir outro tópico para resolver a mesma situação, perdoem-me se estiver errado.
O meu caso o Excel também fica só processando e se eu tentar editar ou adicionar alguma informação dá erro no Excel, como não entendo muito de VBA não sei o que devo melhorar para resolver a situação, se puderem dêem uma olhada pra ver se encontram o problema:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$5" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$B$6" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$E$5" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$E$6" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$B$11" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$B$12" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$E$11" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$E$12" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$B$17" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$B$18" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$E$17" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$E$18" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$B$23" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$B$24" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$E$23" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$E$24" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
If Target.Address = "$B$29" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-1, 0) = Target.Offset(-1, 0) + Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
End If
If Target.Address = "$B$30" Then
If Not IsEmpty(Target) Then
If IsNumeric(Target.Value) Then
Target.Offset(-2, 0) = Target.Offset(-2, 0) - Target.Value
Else
MsgBox "Somente valores numéricos são permitidos!", vbCritical, "Tipos incompatíveis"
End If
End If
Target.ClearContents
Target.Select
End If
End Sub
É o mesmo código, um para Soma e outro para Subtração, porém repetido para várias Células
Desde Já, Obrigado!