Thanks for the help guys, it works with this:
txFoodDiscounts = Format(Val(txmpDisc1.Value) + Val(txmpMiscDisc.Value), "$0.00")
Thanks for the help guys, it works with this:
txFoodDiscounts = Format(Val(txmpDisc1.Value) + Val(txmpMiscDisc.Value), "$0.00")
Yea, however having trouble formating to dollar amounts doing it that way.
my textboxes.
Private Sub txmpDisc1_Change()
If txmpDisc1.Value = "" Then
txmpDisc1.Value = 0
End If
txFoodDiscounts = Format(txmpDisc1.Value, "$0.00") + Format(txmpMiscDisc.Value, "$0.00")
End Sub
Private Sub txmpMiscDisc_Change()
If txmpMiscDisc.Value = "" Then
txmpMiscDisc.Value = 0
End If
txFoodDiscounts = Format(txmpDisc1.Value, "$0.00") + Format(txmpMiscDisc.Value, "$0.00")
End Sub
These two subs are suppose to add the values together. Instead of $1.00 + $1.00 = $2.00, I'm getting $1.00$1.00
Any help is appreciated.
Thanks.
Got this from a person on Mr. Excel. Thanks for the help.
By default, TextBox information is formatted as TEXT. This will convert the values to data type LONG. You can't convert "" (empty) into a zero, so the following will do just that for you:
Private Sub TextBox1_Change()
If TextBox2.Value = "" Then
TextBox2.Value = 0
End If
TextBox3 = CLng(TextBox1.Value) + CLng(TextBox2.Value)
End Sub
Private Sub TextBox2_Change()
If TextBox1.Value = "" Then
TextBox1.Value = 0
End If
TextBox3 = CLng(TextBox1.Value) + CLng(TextBox2.Value)
End Sub
Began learning VBA myself, these are the sights I found:
http://www.vbatutor.com/vbatutor.htm
http://www.fontstuff.com/vba/index.htm
http://www.xl-logic.com/pages/vba.html
I have a simple userform with three textboxs. The first two textboxs you put numbers in. Textbox3 adds both numbers. I want textbox3 to add the first two textboxs together automatically; e.g. you type a 1 in textbox1, textbox3 shows 1, then you type a 1 in textbox2 and textbox3 shows a 2, etc.
I can do this with an add button, but I'd rather it be automatic if possible, well I know its possible I just need to know how to do it!:)
The following macro save data from userform back to the worksheet. Unfortunately (1,7),(1,9),(1,11),(1,13),(1,15) & (1,17) have formula's in the worksheet. I need to know the method of saving the formula's back to the worksheet instead of just the values. Any help is appreciated.
Thanks.
vaData(1, 1) = txProduct.Value
vaData(1, 2) = txItemNumber.Value
vaData(1, 3) = txLocation.Value
vaData(1, 4) = txCatagory.Value
vaData(1, 5) = txUnitPrice.Value
vaData(1, 6) = txBegInv.Value
vaData(1, 7) = txBegInvCost.Value
vaData(1, = txPur1.Value
vaData(1, 9) = TxPur1Cost.Value
vaData(1, 10) = txPur2.Value
vaData(1, 11) = txPur2Cost.Value
vaData(1, 12) = txEndInv.Value
vaData(1, 13) = txEndInvCost.Value
vaData(1, 14) = txUseWeek.Value
vaData(1, 15) = txUseWeekCost.Value
vaData(1, 16) = txUsage.Value
vaData(1, 17) = txUsageCost.Value
rgData.Value = vaData