Zeca1456
13-12-2021 22:30:29
Você pode por favor me ajudar no seguinte:
Estou precisando de ajuda para fazer a soma das seguintes txtamount1+ txtamount2+ txtamount3+ txtamount4+ txtamount5+ txtamount6.
Os valores dessas txtamount são gerados automaticamente com o código abaixo.
Private Sub txtQty1_Change()
Dim q As Double
Dim t As Double
If IsNumeric(txtQty1.Value) Then
If txtQty1.Value <> "" Then q = txtQty1.Value
If txtPerUnitInv1.Value <> "" Then t = txtPerUnitInv1.Value
txtAmountInv1.Value = q * t
End If
If txtQty1.Value = "" Then
txtAmountInv1.Value = ""
End If
End Sub
Private Sub txtPerUnitInv1_Change()
Dim q As Double
Dim t As Double
If IsNumeric(txtPerUnitInv1.Value) Then
If txtPerUnitInv1.Value <> "" Then t = txtPerUnitInv1.Value
If txtQty1.Value <> "" Then q = txtQty1.Value
txtAmountInv1.Value = t * q
End If
If txtPerUnitInv1.Value = "" Then
txtAmountInv1.Value = ""
End If
txtPerUnitInv1.Value = Vba.Format(txtPerUnitInv1.Value, "Currency")
End Sub
A soma dessas 6 TextBox tem que preencher a txtSub-Total. Como o código abaixo:
Private Sub txtAmountInv6_Exit(ByVal Cancel As MSForms.ReturnBoolean)
v6 = 0
If Not VBA.IsNumeric(txtAmountInv6.Value) Then
Cancel = True
Else
v6 = VBA.CDbl(txtAmountInv6.Value)
End If
End Sub
Private Sub CommandButton2_Click()
Me.txtSub_Total.Value = v1 + v2 + v3 + v4 + v5 + v6
txtSub_Total.Value = VBA.Format(txtSub_Total.Value, "Currency")
End Sub
Esses códigos estão preenchendo a fazendo os cálculos necessários. Acontece que tenho que apertar a tecla “ENTER” em cada uma das txtamount, mesmo com elas já preenchidas e logo clicar no “Botão de Comando” para realizar a soma.
Como posso realizar isso sem ter que apertar o botão “Enter”?
Além dessa TextBox
Tenho outras 4 txtAmoutoToPay os códigos são semelhantes.
Essa txtAmoutToPay tem que ser somadas entre si somar a txtSub_total.
O código também está pronto, porem com o mesmo problema em apertar a tecla “Enter”.
Estou precisando de ajuda para fazer a soma das seguintes txtamount1+ txtamount2+ txtamount3+ txtamount4+ txtamount5+ txtamount6.
Os valores dessas txtamount são gerados automaticamente com o código abaixo.
Private Sub txtQty1_Change()
Dim q As Double
Dim t As Double
If IsNumeric(txtQty1.Value) Then
If txtQty1.Value <> "" Then q = txtQty1.Value
If txtPerUnitInv1.Value <> "" Then t = txtPerUnitInv1.Value
txtAmountInv1.Value = q * t
End If
If txtQty1.Value = "" Then
txtAmountInv1.Value = ""
End If
End Sub
Private Sub txtPerUnitInv1_Change()
Dim q As Double
Dim t As Double
If IsNumeric(txtPerUnitInv1.Value) Then
If txtPerUnitInv1.Value <> "" Then t = txtPerUnitInv1.Value
If txtQty1.Value <> "" Then q = txtQty1.Value
txtAmountInv1.Value = t * q
End If
If txtPerUnitInv1.Value = "" Then
txtAmountInv1.Value = ""
End If
txtPerUnitInv1.Value = Vba.Format(txtPerUnitInv1.Value, "Currency")
End Sub
A soma dessas 6 TextBox tem que preencher a txtSub-Total. Como o código abaixo:
Private Sub txtAmountInv6_Exit(ByVal Cancel As MSForms.ReturnBoolean)
v6 = 0
If Not VBA.IsNumeric(txtAmountInv6.Value) Then
Cancel = True
Else
v6 = VBA.CDbl(txtAmountInv6.Value)
End If
End Sub
Private Sub CommandButton2_Click()
Me.txtSub_Total.Value = v1 + v2 + v3 + v4 + v5 + v6
txtSub_Total.Value = VBA.Format(txtSub_Total.Value, "Currency")
End Sub
Esses códigos estão preenchendo a fazendo os cálculos necessários. Acontece que tenho que apertar a tecla “ENTER” em cada uma das txtamount, mesmo com elas já preenchidas e logo clicar no “Botão de Comando” para realizar a soma.
Como posso realizar isso sem ter que apertar o botão “Enter”?
Além dessa TextBox
Tenho outras 4 txtAmoutoToPay os códigos são semelhantes.
Essa txtAmoutToPay tem que ser somadas entre si somar a txtSub_total.
O código também está pronto, porem com o mesmo problema em apertar a tecla “Enter”.