Allow only certain alphanumeric data in a range

patni

Board Regular
Joined
Jul 22, 2018
Messages
58
Hey guys,
I need a small help.

In my sheet "PRODUCT" range "A1:A150" I want it to only only certain alphanumeric data.
I want it to allow only "AK1, AK2, AK3, AK4, AK5 ....... AK100" and "OR1, OR2, OR3, OR4, OR5 ..... OR100"

If a user enters anything other than this, then I dont want excel to allow it. Probably give a error message saying "Wrong Code Entered"

Also , I already have this in my data valididation
Code:
=COUNTIF($A:$A,A11)=1
. This prevents duplicate entries

Can anyone please help me.

THANK YOU
 
Last edited:
Re: How to allow only certain alphanumeric data in a range

Hey Rick Rothstein,
I just checked that.

Okay this is something intresting. Is there any ways to prevent this ?
Just very curious
 
Last edited:
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Re: How to allow only certain alphanumeric data in a range

Hey Special K 99,

Is it possible to add 2 more criteria in the code ? (Sorry for the trouble)
I mean we have "AK" and "OR" in the code below.

Is it possible to add "LE" and "LK" as well?

So total we have 4 criteria "AK" "OR" "LE" "LK"

Code:
[COLOR=#333333]=AND(NOT(ISNUMBER(SEARCH(" ",A8))),OR(LEFT(A8,2)="AK",LEFT(A8,2)="OR"),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$8:A$1000,A8)=1[/COLOR]
 
Last edited:
Upvote 0
Re: How to allow only certain alphanumeric data in a range

I tried this but something is wrong I guess. could you check please.
THANK YOU SO MUCH

Code:
[COLOR=#333333]=AND(NOT(ISNUMBER(SEARCH(" ",A8))),OR(LEFT(A8,2)="AK",[/COLOR]LEFT(A8,2)="LE",LEFT(A8,2)="LK",LEFT(A8,2)="OR"),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0>=1RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$8:A$1000,A8)=1
 
Upvote 0
Re: How to allow only certain alphanumeric data in a range

Hey Rick Rothstein,
I just checked that.

Okay this is something intresting. Is there any ways to prevent this ?
Just very curious
The only way to have fool-proof data validation is by using properly designed Change event coding.
 
Upvote 0
Re: How to allow only certain alphanumeric data in a range

I tried this but something is wrong I guess. could you check please.
THANK YOU SO MUCH

Code:
[COLOR=#333333]=AND(NOT(ISNUMBER(SEARCH(" ",A8))),OR(LEFT(A8,2)="AK",[/COLOR]LEFT(A8,2)="LE",LEFT(A8,2)="LK",LEFT(A8,2)="OR"),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0>=1[color=red][b],[/b][/color]RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$8:A$1000,A8)=1

You've deleted a comma after the second RIGHT, see highlighted
 
Upvote 0
Re: How to allow only certain alphanumeric data in a range

And you've deleted the closing brackets and changed the COUNTIF formula so it doesnt work
This is what it should be

=AND(NOT(ISNUMBER(SEARCH(" ",A8))),(OR(LEFT(A8,2)="LE",OR(LEFT(A8,2)="LK",OR(LEFT(A8,2)="AK",LEFT(A8,2)="OR")))),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$1:A$1000,A8)=1)

If you're gonna change cell references in this formula then only change the references to cell A8 - NO OTHER CELL REFERENCES or you're undoing the work I've done for you.
 
Last edited:
Upvote 0
Re: How to allow only certain alphanumeric data in a range

Hey Special K99 ,
Sure.
Thank you so much for the help.
I checked my mistake and hopefully i learn from it.

The code works perfectly now.
Thank you for the help
 
Upvote 0
Re: How to allow only certain alphanumeric data in a range

Hey Special K99,
I need help regarding this thread.
In the previous formulae we had allowed "LK" , "AK", "AE", OR" codes from 1 to 100

I want to add 3 more to this formulae. I want to add "NL" , "BA" , and "CH" (same as previous from 1 to 100)

Could you help me please. I am unable to crack it.
Thank you




And you've deleted the closing brackets and changed the COUNTIF formula so it doesnt work
This is what it should be

=AND(NOT(ISNUMBER(SEARCH(" ",A8))),(OR(LEFT(A8,2)="LE",OR(LEFT(A8,2)="LK",OR(LEFT(A8,2)="AK",LEFT(A8,2)="OR")))),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$1:A$1000,A8)=1)

If you're gonna change cell references in this formula then only change the references to cell A8 - NO OTHER CELL REFERENCES or you're undoing the work I've done for you.
 
Upvote 0
Re: How to allow only certain alphanumeric data in a range

Try (untested)

=AND(NOT(ISNUMBER(SEARCH(" ",A8))),OR(LEFT(A8,2)="LE",LEFT(A8,2)="LK",LEFT(A8,2)="AK",LEFT(A8,2)="OR",LEFT(A8,2)="NL",LEFT(A8,2)="BA",LEFT(A8,2)="CH"),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$1:A$1000,A8)=1)
 
Last edited:
Upvote 0
Re: How to allow only certain alphanumeric data in a range

Hey Special K99,
thank you for the reply.

The above code is not working. I am not able to input any data as of now.
Whatever I type, excel data valididation stops me from typing.


Try (untested)

=AND(NOT(ISNUMBER(SEARCH(" ",A8))),OR(LEFT(A8,2)="LE",LEFT(A8,2)="LK",LEFT(A8,2)="AK",LEFT(A8,2)="OR",LEFT(A8,2)="NL",LEFT(A8,2)="BA",LEFT(A8,2)="CH"),RIGHT(A8,LEN(A8)-2)+0>=1,RIGHT(A8,LEN(A8)-2)+0<=100,COUNTIF(A$1:A$1000,A8)=1)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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