I am new to vba and I have a simple userform in excel. First textbox is qty1txt * second textbox is rate1txt = amount1txt. On the next line is forth textbox is qty2txt * fifthtextbox is rate2txt = amount2txt. Then I have a command button (Calculate total) in my totaltxt textbox. Some times I do not have information and want to have blank textboxes of qty2txt, rate2txt and amount2txt, but I still need a total. This is what I have so far. Any help would be appreciated. Thank you
Option Explicit
Private Sub CommandButton1_Click()
totaltxt.Value = (qty1txt.Value) * (rate1txt.Value) + (qty2txt.Value) * (rate2txt.Value)
End Sub
Private Sub rate1txt_Change()
'calculate the product
amount1txt.Value = (qty1txt.Value) * (rate1txt.Value)
End Sub
Private Sub rate2txt_Change()
'calculate the product
amount2txt.Value = (qty2txt.Value) * (rate2txt.Value)
End Sub
Option Explicit
Private Sub CommandButton1_Click()
totaltxt.Value = (qty1txt.Value) * (rate1txt.Value) + (qty2txt.Value) * (rate2txt.Value)
End Sub
Private Sub rate1txt_Change()
'calculate the product
amount1txt.Value = (qty1txt.Value) * (rate1txt.Value)
End Sub
Private Sub rate2txt_Change()
'calculate the product
amount2txt.Value = (qty2txt.Value) * (rate2txt.Value)
End Sub