Data Validation Letters and Numbers

forrestgump

New Member
Joined
Sep 30, 2010
Messages
22
Hi There, I want to create data validation so that the first 2 digits=PS and the next 4 digits will be numbers. I have tried a few things but I cant get anything to work? any help would be much appreciated.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772
This should do the trick...

=AND(LEFT(A1,2)="PS",ISNUMBER(MID(A1,3,4)+0))
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
This should do the trick...

=AND(LEFT(A1,2)="PS",ISNUMBER(MID(A1,3,4)+0))

I thought so too, but this
ISNUMBER(MID(A1,3,4)+0
will allow for only 3 numbers after PS

That's why I added the LEN=6
 

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,772

ADVERTISEMENT

I thought so too, but this
ISNUMBER(MID(A1,3,4)+0
will allow for only 3 numbers after PS

That's why I added the LEN=6

Good point, but the OP didn't actually specify that the string should be limited to 6 characters.
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Good point, but the OP didn't actually specify that the string should be limited to 6 characters.
hmm..
Hi There, I want to create data validation so that the first 2 digits=PS and the next 4 digits will be numbers. I have tried a few things but I cant get anything to work? any help would be much appreciated.
2+4 = 6

Perhaps it should be
>=6 instead of =6
 

forrestgump

New Member
Joined
Sep 30, 2010
Messages
22

ADVERTISEMENT

Thanks everyone. I went with =AND(LEFT(A1,2)="PS",MID(A1,3,4)+0,LEN(A1)=6). The part of the formula I don't understand is the +0. What does this do?
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
Mid returns a TEXT string, the +0 converts that to a number.
And any number other than 0 works as a TRUE result for the AND function.
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
37,881
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Thanks everyone. I went with =AND(LEFT(A1,2)="PS",MID(A1,3,4)+0,LEN(A1)=6). The part of the formula I don't understand is the +0. What does this do?
That will work as long as you do not get an entry similar in structure to these... PS9e34, PS+9e4, PS(12), etc.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,028
Messages
5,835,032
Members
430,333
Latest member
jaypatel1298

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
Top