Statement working in a cell but not in data validation

gerotutu

New Member
Joined
Jun 19, 2015
Messages
28
I need to check if the field that is completed in column W is a number of at least 7 characters. I cannot allow anything different, except when in column V is "TARJETA_CREDITO".

In the case the field in column V is "TARJETA_CREDITO" the previous validation needs to be changed to XOR you may see below (they are some basic rules to validate different types of credit cards).


I tried this formula out in a normal cell and it works but it does not work properly when I use it as data validation. As data validation it only works when selecting "TARJETA_CREDITO".

The basic idea would be: IF V=TARJETA_CREDITO THEN Check W is a credit card number ELSE Check W is a number and with a length of at least 7 characters.

=IF(V3="TARJETA_CREDITO";
AND(ISNUMBER(VALUE(W3));XOR(AND(LENGTH(W3)=14;LEFT(W3;2)="36");AND(LENGTH(W3)=16;OR(LEFT(W3;1)="5";LEFT(W3;1)="4"));AND(LENGTH(W3)=15;LEFT(W3;2)="37")));
AND(LENGTH(W3)>=7;ISNUMBER(VALUE(W3)))
)

The second path of the IF never works in data validation. I don't get why! Hope you can help me...

Thanks, again!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I translated wrong the formula to the English syntax

=IF(V3="TARJETA_CREDITO",
AND(ISNUMBER(VALUE(W3)),XOR(AND(LEN(W3)=14,LEFT(W3,2)="36"),AND(LEN(W3)=16,OR(LEFT(W3,1)="5",LEFT(W3,1)="4")),AND(LEN(W3)=15,LEFT(W3,2)="37"))),
AND(LEN(W3)>=7,ISNUMBER(VALUE(W3)))
)
 
Upvote 0
I just unmark the option to "Omitir blancos" ("Skip blanks") and it started working. I had yesterday all the day lost because of this. Don't know now how exactly that option works.


Lesson learnt. Thanks,
Gerónimo
 
Upvote 0

Forum statistics

Threads
1,215,965
Messages
6,127,970
Members
449,414
Latest member
sameri

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