Data validation and numbers + hyphens

Jordytee

New Member
Joined
Nov 8, 2018
Messages
6
Hi there all, i want to set a data validation rule so that only the following number sequence can be entered to a cell: 000000-00
the hyphen is a must, if i didnt need the hyphen I would be fine setting this up. Any ideas?

I use the data validation from the ribbon, and need a custom formula
 
Maybe:

=B2=TEXT(--REPLACE(B2,7,1,""),"000000-00")

Hi there :) this almost works! But what about if i want to continue the data validation down through the column, the whole column to be precise. I have tried replacing B2 with $E2 (E is the column where my data is) i have also tried E:E

Any ideas?
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
If you want to apply the data validation rule to the entire column E:

- select the column;
- open the Data Validation dialog;
- place the following rule in the Formula field: =$E1=TEXT(--REPLACE($E1,7,1,""),"000000-00")
 
Upvote 0
I think you can just use OR:

=OR($E1="Specific phrase",$E1=TEXT(--REPLACE($E1,7,1,""),"000000-00"))

Click Yes when it says evaluates to an error.
 
Last edited:
Upvote 0
Scott,

No, OR will not work here because it has to evaluate both conditions. So, when we try to enter "Specific phrase" in the cell:
- the first condition evaluates to TRUE,
- the second condition evaluates to #VALUE !,
- the OR returns #VALUE !, and
- the Data Validation rejects the entry as invalid.
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,596
Members
452,657
Latest member
giadungthienduyen

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