Cell to have only 2 letters and 4 numbers

Malcolm torishi

Board Regular
Joined
Apr 26, 2013
Messages
219
Is it possible to ensure a user can only type into a cell two letters say “ks” followed by four numbers . So if a user forgets either the letters or four numbers he will be prompted.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
if your data is in cell A1,

then use data validation > Custom with the following rule;

=AND(LEN(A1)=6,ISTEXT(LEFT(A1,2)),ISNUMBER(VALUE(RIGHT(A1,4))))

then copy down through column A, or adjust as necessary.

This works on Mac, you may have to change ISNUMBER for ISNUMERIC for windows, I'm not 100% sure though.

=AND multiple checks to be true

(LEN(A1)=6, Length of A1 should be 6 characters long

ISTEXT(LEFT(A1,2)), left 2 characters of A1 should be text

ISNUMBER(VALUE(RIGHT(A1,4)))) ​value (change text to a number), of the right 4 characters of A1 should be numbers
 
Last edited:
Upvote 0
if your data is in cell A1,

then use data validation > Custom with the following rule;

=AND(LEN(A1)=6,ISTEXT(LEFT(A1,2)),ISNUMBER(VALUE(RIGHT(A1,4))))

then copy down through column A, or adjust as necessary.
What do you think should happen if the user types in AB3E45 or AB3OCT? Does what you thought actually happen?
 
Upvote 0
=product(-iserror(-mid(a1, {1,2}, 1)), -isnumber(-mid(a1, {3,4,5,6}, 1)))
 
Upvote 0
AB3E45 - Eulers number would probably pass the test, not sure on the other one. Nor am I aware how to check/counter this.
 
Upvote 0
Hello.
My contribution.
Forgive translated English.
The formula looks like this:

in data validation select "custom" and type this formula

Code:
=SUMPRODUCT(--(LEFT($D4;2)="ks");--(SUMPRODUCT(--ISNUMBER(--MID($D4;ROW(INDIRECT("3:"&LEN($D4)));1)))=4);--(LEN($D4)=6))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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