-
an empty textbox in a formula
i have form
this form calculate this formula : TextBox1 * TextBox2 = TextBox3.
but when textbox1 or TextBox2 is empty , there is "run time error 13 type mismatch"
what can i do to make the formula to work ok when one textbox is empty (ie 6 * " " = 0) ?
-
Use a function to convert "" to 0
[VBA]Private Sub CommandButton1_Click()
TextBox3.Value = FixTB(TextBox1.Value) * FixTB(TextBox2.Value)
End Sub
Function FixTB(Num)
If Num = "" Then
FixTB = 0
Else
FixTB = Num
End If
End Function
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules