Validation Rule

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
I am using an input mask of ">aaaaaaaaa" for a text field that I want to only accept letters a-Z and and digits 0-9 (no spaces or symbolics). But I can't quite get the validation rule right. Any thoughts?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi
Try AAAAAAAAA for 9 compulsory characters and / or digits. Change to lower case for optional.
Andrew
 
Upvote 0
Two issues I ran into with that. It allows spaces and if you use it as an input mask you cannot give a friendly error.
 
Upvote 0
The lower case 'a' allows spaces but the upper case doesn't. The lower case example means the user doesn't have to enter all of the characters - that's why you are seeing that anomaly. I agree the error messages are a bit unhelpful for the average user. If you want a variable length without spaces and custom error messages you may want to write your own validation rule using VBA on the BeforeUpdate event.

HTH, Andrew
 
Upvote 0
*sigh* That was my conclusion too. I was just hoping someone knew something that could be done at the table level. Appreciate the input :)
 
Upvote 0
If the first n characters are compulsory, how about something like >AAAaaaaaa? That way you won't have any spaces in the first n characters.
Andrew
 
Upvote 0
I just changed it to a fixed length all numeric field and avoided the issue all together :oops:
 
Upvote 0
That IS good info (thank you), but I was already aware of it's information. It does not, unfortunatly, cover what I was trying to do. The origianl goal was to create an input mask or data validation rule that allows alphas & numerics but not symbolics or spaces while still retaining a variable length structure. I actually found a decent workaround I think with using an input mask of "aaaaaaaaa" then using the validation rule of Instr([MyField]," ") = 0. This combination seems to have accomplished the goal mostly.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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