Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
I have a formula that obtains it values from a userform and a spreadsheet. The problem is if any value is missing from either the userform or mainly the spreadsheet, I should get a Runtime-error 11 'Division by zero, which I do, as expected. So I wrote this little snippet of code, within a Sub, to to do something else when that runtime error fires. The problem is no matter where I place the code it still displays the Runtime-error message and not my code. So I am assuming its an issue of where the code is located. However, I noticed no matter where I put it, it still does execute. I tried putting in the beginning of the sub after I declared my variables, which to me was way to soon because the formula is later in the code. So I tried after the formula and Runtime error still displays. So I'm stuck for the moment. Any help would be greatly appreciated. If there is any error in my code, please let me know how I can fix it also. Thank you.
Error occurs in the first line of code when I debugged it:
Code:
Sub ErrorTrap11()
If Err.Number = 11 Then
MsgBox Chattemfrm.cmbPrdCde.Value & " not found or is missing values in Product list. Please add missing product to the product list or fill in missing data in order to continue.", vbOKOnly + vbCritical + vbDefaultButton1, "Missing Information"
Worksheets(Chattemfrm.cmbSDPFLine.Value).Activate
Unload Me
frmAddProduct.Show
Exit Sub
End If
End Sub
Error occurs in the first line of code when I debugged it:
Code:
textValUp = ((txtbxdz.Value) / txtDz / txtCs) + 0.5 - 1E-16
textValDown = ((txtbxdz.Value) / txtDz / txtCs) - 0.5 + 1E-16