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.
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

njimack

Well-known Member
Joined
Jun 17, 2005
Messages
7,764
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,764

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
36,690
Office Version
  1. 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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,809
Messages
5,598,202
Members
414,218
Latest member
speedbit

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