Jump to content

Recommended Posts

Posted

Boa noite pessoal, como vão?

Sou novo no forum e preciso muito da ajuda de vocês. Estou trabalhando com uma planilha que não apresentava problemas até pouco tempo atrás, mas, após formatação do PC em que trabalho, ela começou à apresentar este ERRO.

Sou muito leigo em VBA, então, realmente preciso de ajuda tipo "passo-a-passo". Quando clico em "depurar" e abro o VBA, este seleciona de amarelo a parte em que expus em negrito e sublinhado:

Desde já agradeço.

Private Sub Botão_OK_Click()

'If Sheets("Simulação").Range("E8") = "10605-4" Then
'	If Me.Rendimento > 2500 Then
'		MsgBox "Digite um valor de Benefício <= R$2.500,00 !", vbCritical
'		Me.Rendimento.SetFocus
'		Exit Sub
'	End If
'Else
'	If Me.Rendimento > 2500 Then
'		MsgBox "Digite um valor de Rendimento Líquido <= R$2.500,00 !", vbCritical
'		Me.Rendimento.SetFocus
'		Exit Sub
'	End If
'End If

'	If Sheets("Simulação").Range("a2") = "1" Then
'			Me.Remuneração = 0#
'			Me.Remuneração.SetFocus
	  '  Exit Sub
'   Else
'				Me.Remuneração = 0
'				If Me.Remuneração > 0 Then
'				Beep
'				MsgBox "A Remuneração do CCA deve ser 0 ", vbCritical
'				'Me.Remuneração.SetFocus
'				Me.Remuneração = 0
'				Exit Sub
'				End If
'End If

If Me.Valor = Empty Then
	Beep
	MsgBox "Digite um valor válido!", vbCritical
	Me.Valor.SetFocus
	Exit Sub
End If

If Me.DataConc = Empty Or Not IsDate(Me.DataConc) Then
	Beep
	MsgBox "Digite uma data válida!", vbCritical
	Me.DataConc.SetFocus
	Exit Sub
End If

If Me.Prazo = Empty Or Val(Me.Prazo) > Sheets("Simulação").Range("Y9") Then
	Beep
	MsgBox "Digite um prazo <= " & Sheets("Simulação").Range("Y9"), vbCritical
	Me.Prazo.SetFocus
	Exit Sub
End If


Dim int_Aux As Range
Dim Ln, Num As Long
Set int_Aux = Sheets("Convenente").Columns(1).Find("*", searchDirection:=xlPrevious)
Ln = int_Aux.Row


Volta:

Sheets("Cálculo").Range("C13") = CDate(DataConc.Value)
Sheets("Cálculo").Range("C5") = CSng(Prazo.Value)
'	Sheets("Cálculo").Range("L4") = CSng(Remuneração.Value)
Sheets("Cálculo").Range("c3") = CSng(SaldoDevedor.Value)

If Prazo.Value < 7 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],6,FALSE)/100"
	Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],6,FALSE)/100"
ElseIf Prazo.Value < 13 Then
 '	  Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],7,FALSE)/100"
	Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],7,FALSE)/100"
ElseIf Prazo.Value < 25 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],8,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],8,FALSE)/100"
ElseIf Prazo.Value < 37 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],9,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],9,FALSE)/100"
ElseIf Prazo.Value < 49 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],10,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],10,FALSE)/100"
ElseIf Prazo.Value < 61 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],11,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],11,FALSE)/100"
ElseIf Prazo.Value < 73 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],12,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],12,FALSE)/100"
ElseIf Prazo.Value < 97 Then
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],12,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],13,FALSE)/100"

Else
'	   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[9],13,FALSE)/100"
   Sheets("Cálculo").Range("C6").FormulaR1C1 = "=VLOOKUP(Simulação!R[3]C[4],Convenente!R[-3]C[-2]:R[" & Ln - 6 & "]C[11],14,FALSE)/100"
End If

'	If OptionButton1.Value = False Then
'		Sheets("Cálculo").Range("C4") = CDbl(Valor.Value)
'	End If

If OptionButton2.Value = True Then
   ' Sheets("Cálculo").Range("C11").GoalSeek Goal:=CDbl(Valor.Value), ChangingCell:=Sheets("Cálculo").Range("C11")
	Sheets("Cálculo").Range("C11") = CDbl(Valor.Value)

End If

If OptionButton3.Value = True Then
	Sheets("Cálculo").Range("C146").GoalSeek Goal:=CDbl(Valor.Value) * -1, ChangingCell:=Sheets("Cálculo").Range("C11")
End If


If Sheets("Simulação").Range("E8") = "10605-4" Then
[u][b]		If Sheets("Cálculo").Range("C21") * -1 >= Me.Rendimento * 0.3 Then[/b][/u]
		MsgBox "Prestação maior que o permitido! Será apresentado cálculo do valor máximo", vbCritical
		Sheets("Cálculo").Range("C21").GoalSeek Goal:=Me.Rendimento * -0.3, ChangingCell:=Sheets("Cálculo").Range("C4")
	End If
Else
	If Sheets("Cálculo").Range("C21") * -1 >= Me.Rendimento * 0.3 Then
		MsgBox "Prestação maior que o permitido! Será apresentado cálculo do valor máximo", vbCritical
		Sheets("Cálculo").Range("C21").GoalSeek Goal:=Me.Rendimento * -0.3, ChangingCell:=Sheets("Cálculo").Range("C4")
	End If
End If

'   If OptionButton1.Value <> True Then

'   Me.Valor = Round(Plan2.Cells(4, 3), 2)
'  OptionButton1.Value = True

'   GoTo Volta
'   End If


Escolha.Hide

End Sub

Private Sub DataConc_Change()

End Sub

Private Sub Label10_Click()

End Sub

Private Sub TextBox2_Change()

End Sub

Private Sub OptionButton4_Click()

End Sub

Private Sub Label12_Click()

End Sub

Private Sub Label13_Click()

End Sub

Private Sub Label9_Click()

End Sub

Private Sub OptionButton1_Click()

End Sub

Private Sub Label2_Click()

End Sub

Private Sub OptionButton2_Click()

End Sub

Private Sub Prazo_Change()

End Sub

Private Sub Remuneração_Change()

End Sub

Private Sub TextBox1_Change()

End Sub

Private Sub Rendimento_Change()

End Sub

Private Sub SaldoDevedor_Change()

End Sub

Private Sub UserForm_Initialize()
If Sheets("Simulação").Range("E8") = "10605-4" Then
	LabelRendimento.Caption = "Renda do Cliente"
   ' LabelRemuneração.Caption = 0

Else
	LabelRendimento.Caption = "Renda do Cliente"
   ' LabelRemuneração.Caption = 2
End If

End Sub

Private Sub Valor_Change()

End Sub
Posted

Frederico Bakunin,

Boa Noite!

Altere a linha:

If Sheets("Cálculo").Range("C21") * -1 >= Me.Rendimento * 0.3 Then

Se os números forem inteiros, para:

If CInt(Sheets("Cálculo").Range("C21")) * -1 >= CInt(Me.Rendimento) * 0.3 Then

Se os números forem decimais, para:

If CDbl(Sheets("Cálculo").Range("C21")) * -1 >= CDbl(Me.Rendimento) * 0.3 Then

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.