vbanewbie2
New Member
- Joined
- Jul 18, 2010
- Messages
- 6
Hi
I have four cells in excel that I need to add into a fifth cell.
cells A1, A9, A10 and A15 (input) (=sum (A1+A9+A10+A15))
cell A23 is the total
My problem if one of the cells are blank it does not add up and gives me and error (run time error 13)
how do I go about correcting this.
the output (total) goes into a textbox on my user form.
I have four cells in excel that I need to add into a fifth cell.
cells A1, A9, A10 and A15 (input) (=sum (A1+A9+A10+A15))
cell A23 is the total
My problem if one of the cells are blank it does not add up and gives me and error (run time error 13)
how do I go about correcting this.
the output (total) goes into a textbox on my user form.
Code:
Dim STRTOTAL As String
Dim INTNUM1 As Integer
Dim INTNUM2 As Integer
Dim intNUM3 As Integer
Dim intNUM4, INTANSWER As Integer
STRTOTAL = Me.txttotal.Value
INTNUM1 = txtamt1.Value
INTNUM2 = txtamt2.Value
INTNUM3 = txtamt3.Value
INTNUM4 = txtamt4.Value
If STRTOTAL = "" Then
INTANSWER = INTNUM1 + INTNUM2 + INTNUM3 + INTNUM4
Me.txttotal.Text = " SUM; " & INTANSWER
End If