Data Validation - two formats only

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi there,

I would like to have a column which only accepts the following two formats to be entered;

### or ###/###

Example;
499 or 499/001

I'm guessing I can do this under Data Validation??:confused:

Thanks for your time!
 

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.
Data Validation restricts the type of data entered in a cell, not the format of the data.

Assuming ### or ###/### where the #'s are digits and do not all have to be the same is what you want, this DV custom formula seems to work. In this case it's applied to range P4:P10, change the range to suit your application.
Code:
=OR(AND(ISNUMBER(P4),LEN(P4)=3),AND(ISNUMBER(LEFT(P4,3)+0),ISNUMBER(RIGHT(P4,3)+0),ISNUMBER(SEARCH("/",P4)),LEN(P4)=7))
 
Upvote 0
For the same range JoeMo assumed, I am pretty sure this shorter data validation formula will also work...

=((LEN(P4)=3)+(LEN(P4)=7))*ISNUMBER(-REPLACE(P4,4,1,""))*(MID(P4&"/",4,1)="/")
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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