ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   generating text box value based on equation from other boxes (https://www.excelbanter.com/excel-programming/362128-generating-text-box-value-based-equation-other-boxes.html)

Craig[_24_]

generating text box value based on equation from other boxes
 
I've got an invoicing macro that totals 4 amount boxes and a amount
paid box (input boxes on the form). I'm trying to get the total box to
update based on the amounts in this box, but i keep getting a type
mismatch, here's what i have for the change events on the five inpute
boxes

Private Sub FirstAmtBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
BalanceDueAmountBox.Value = ((FirstAmtBox.Value * 1) +
(SecondAmtBox.Value * 1) + _
(ThirdAmtBox.Value * 1) + (FourthAmtBox.Value * 1) -
(AmtPaidBox.Value * 1))
End Sub

any suggestions?


Leith Ross[_558_]

generating text box value based on equation from other boxes
 

Hello Craig,

Try this...

Private Sub FirstAmtBox_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim AmountDue
AmountDue = CCur(FirstAmtBox.Text ) +
CCur(SecondAmtBox.Text ) + _
CCur(ThirdAmtBox.Text ) + CCur(FourthAmtBox.Text) -
CCur(AmtPaidBox.Text)
BalanceDueAmountBox.Text = Format(AmountDue, "Currency")
End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=544532


C01d[_5_]

generating text box value based on equation from other boxes
 

Your code seems to run fine. You might want to check that you have named
your textboxes correctly as using a wrong name will cause a new variable
to be declared. This new variable will be given the Variant type,
causing the type mismatch error.


--
C01d
------------------------------------------------------------------------
C01d's Profile: http://www.excelforum.com/member.php...o&userid=34422
View this thread: http://www.excelforum.com/showthread...hreadid=544532



All times are GMT +1. The time now is 06:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com