Hi, I am fairly new to VBA, so this might be rather trivial. I have a Userform with a Text Box to enter a number. I want to check, if there was a number entered in the Text Box. If a number was entered, a certain calculation is to be done with that number If no number was entered, then this Text Box is rated with a certain grade (e.g. 10) and further calculation is to be done with that grade. I have written the code below: Dim A As Variant Dim B As Variant Private Sub btnCheck_Click() If txtA.Text = "" Then Msg = "You have entered no value for A. Do you want to continue?" Ans = MsgBox(Msg, vbYesNo) If Ans = vbNo Then Exit Sub If Ans = vbYes Then txtA.Text = ?#N/A? End If A = txtA.Text If A = ?#N/A? Then B = 10 If A > 0 And A <= 400 Then B = 0 If A > 400 Then B = (A - 400) * 0.1 The above does not work. If I exchange "#N/A" with a number, such as "0", then everything works fine. However, this is not what I want. How do I assign an 'empty' Text Box to a variable? Thanks,
This question generated 15 answers. To proceed to the answers, click here.
This thread is current as of December 16, 2014.
For more resources for Microsoft Excel:
This article includes the following tags:
- Microsoft Excel