Data validation with multiple conditions (OR)

Olia2

New Member
Joined
Oct 13, 2016
Messages
6
Hi guys,

I hope you can help me, as I've tried many different options and am out of options (excel will not accept my formula).

I am trying to construct data validation *custom*, where user can only insert phone number OR email address; this is what I have figured out so far:


=OR(A1=ISNUMBER(MATCH("*@*.?*",A1,0))),(A1=(ISNUMBER(A1),LEN(A1)=10))

Could anyone point me where I am making the mistake? I've been trying to figure this out for the past 2 hours.

Thanks a million in advance!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
OK let's break this into two sections.

Dealing with the phone number bit first, this formula will only allow input of a 10 digit number
=AND(ISNUMBER(A1),LEN(A1)=10)

For the email address, exactly what criteria do you want to use, to determine that the input is an email address ?
Do you simply want to check that the string of characters contains a "@" symbol, or is it more complicated ?
 
Upvote 0
Hi Gerald,

Thank you for your response.

Regarding your questions:
1. Yes, only 10 digits should be allowed
2. The point of my formula was verify that there is @ symbol in the text string, and ". + n characters" behind it;

I hope it's clear :)

And huge thank you.
 
Upvote 0
Do you need to define n or can it have any value ?

Have you tested my proposal in post #2 to check that it handles telephone numbers the way you want ?
For example, my proposal WILL allow input of a number such as 1234.56789
And it will NOT allow input of a number such as 0123456789
Is this OK ?
 
Upvote 0
n can have any value, as different email domains can be used.

Telephone number formula is tested and is OK :)
 
Upvote 0
OK, try this . . .

=OR(ISNUMBER(SEARCH("?@?.?",A1,1)),AND(ISNUMBER(A1),LEN(A1)=10))

Input of Z@Z.Z will be allowed.
Input of Z@Z will not be allowed.
 
Upvote 0
Hi Gerald,

amazing thanks! I adjusted the formula a bit to fit my purposes (your suggestion would not allow me to enter the email address), the only thing missing: the formula does not allow the number to start with 0 (zero) - excel formats it in number and thus removes the 0 turning the number in 9 digits.

Is there any trick to keep the formula and add possibility for phone number to start with zero?

=OR(ISNUMBER(MATCH("*@*.?*",A1,0)),AND(ISNUMBER(A1),LEN(A1)=10))
 
Upvote 0
If you want to allow numbers starting with zero, you're probably going to have to store them as text strings.

You can still use data validation to check that what is input is actually a number in a text format, for example . . .
=OR(ISNUMBER(MATCH("*@*.?*",A1,0)),AND(ISNUMBER(A1+0),LEN(A1)=10))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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