IsNumeric

Sherrise

New Member
Joined
Oct 25, 2021
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I have a TxtBox with a number in it. I want to have a validation. If blank a message comes up, if it is not a numeric number a message comes up. The first If statement works, but not the IsNumeric!
2014-151566

This is my coding. What am I doing wrong?

If Me.TxtCaseNumber.Value = "" Then
MsgBox "This field must be field in with a numeric #", vbCritical
Exit Sub
End If


If IsNumeric(Me.TxtCaseNumber & "e-0".Value) = False Then
MsgBox "Please enter a Numeric Number", vbCritical
Exit Sub
End If
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I want to make sure that the field can not be left blank and only a numeric number.
Example of TxtCaseNumber
2014-551689
 
Upvote 0
It would be wonderful if the TxtCaseNumber background field would turn a different color as well.
 
Upvote 0
I am very sorry I am very new at this! I don't know what you mean. I have created a excel VBA Form.

1682105422564.png
 
Upvote 0
Your entry of "2014-145644" is not a valid number, because of the "-" in it ("2014-145644 isn't any number that you can count to or do math on, as it is not a valid number).
So you cannot use the IsNumeric function on it.

We will have to use some other method of verify it, but first we need to fully understand what your "rules" are.
Will valid entries always be formatted like this "XXXX-XXXXXX", where you will have 4 number, followed by a comma, followed by 6 numbers?
Is that what you want to check for?
 
Upvote 0
It can be two different was.
The first part "2014" Stands for the year. The other numbers are given to me by someone else to identify the case.
1. 2014-211111
The "M" stands for Master Case. 2015 stand for the year.
2. M2015-205555

I want this field to be a required field and if they click on the save button and it is blank the field will turn a different color and a message box will appear telling the user "They case number was forgotten."
If they enter 11M2015-1125 the field will turn a different color and message box will appear saying " you have entered the case number incorrectly".

It will always have a dash "-" between the year and the case number.

Example of Errors. If someone entered any of the following the message box would appear.
11M 201511
C2015-1125
CB2015-1125
M-2015-1125

The only 2 ways it would not come up and save would be.
2023-164578 Or M2024-000001

I hope that I am answering your questions!!!
 
Upvote 0

Forum statistics

Threads
1,215,106
Messages
6,123,124
Members
449,096
Latest member
provoking

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top