Data Validation Overriding Itself?

gmbhbls

New Member
Joined
May 8, 2015
Messages
10
I have a single column. If I enter this code into the validation, It does what I want. It constrains the entries so that they start with either "PCO-R0343-" or "DVCO-R0343-".

=OR(AND(LEN(A5)=14,EXACT(LEFT(A5,10),"PCO-R0343-"),ISNUMBER(-MID(A5,ROW(INDIRECT("11:14")),1))),AND(LEN(A5)=15,EXACT(LEFT(A5,11),"DVCO-R0343-"),ISNUMBER(-MID(A5,ROW(INDIRECT("12:15")),1))))

I also have this code. If I remove all validation code and enter this code, instead, it does what I want. It constrains the entries so that the last four characters cannot be duplicated anywhere in the column.

=AND(COUNTIF($A$5:$A$1005,"*-R0343-"&RIGHT(A5,4))=1)

But, If I enter this code (the two prior codes merged together) it's as if the red code is ignored and the blue code is all that's being "enforced".

=OR(AND(LEN(A5)=14,EXACT(LEFT(A5,10),"PCO-R0343-"),ISNUMBER(-MID(A5,ROW(INDIRECT("11:14")),1))),AND(LEN(A5)=15,EXACT(LEFT(A5,11),"DVCO-R0343-"),ISNUMBER(-MID(A5,ROW(INDIRECT("12:15")),1))),AND(COUNTIF($A$5:$A$1005,"*-R0343-"&RIGHT(A5,4))=1))

Does anyone see what may be causing one formula to override the other one?

I thank you in advance for all of your time and effort!

Edit:

I am limited by the number of characters, or I would add in place of the blue code: (COUNTIF($A$5:$A$1005,"PCO-R0343-"&RIGHT(A5,4))=1) and (COUNTIF($A$5:$A$1005,"DVCO-R0343-"&RIGHT(A5,4))=1)
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Now you have

Code:
=OR(AND(LEN(A5)=14, EXACT(LEFT(A5, 10), "PCO-R0343-"),  ISNUMBER(-MID(A5, ROW(INDIRECT("11:14")), 1))),
    AND(LEN(A5)=15, EXACT(LEFT(A5, 11), "DVCO-R0343-"), ISNUMBER(-MID(A5, ROW(INDIRECT("12:15")), 1))),
    AND(COUNTIF($A$5:$A$1005, "*-R0343-"&RIGHT(A5, 4))=1))

I expect you want

Code:
=AND(OR(AND(LEN(A5)=14, EXACT(LEFT(A5, 10), "PCO-R0343-"),  ISNUMBER(-MID(A5, ROW(INDIRECT("11:14")), 1))),
        AND(LEN(A5)=15, EXACT(LEFT(A5, 11), "DVCO-R0343-"), ISNUMBER(-MID(A5, ROW(INDIRECT("12:15")), 1)))),
     COUNTIF($A$5:$A$1005, "*-R0343-" & RIGHT(A5, 4))=1)
 
Upvote 0
Thank you, shg! That's exactly what I was trying to accomplish! I appreciate your help!

Now you have

Code:
=OR(AND(LEN(A5)=14, EXACT(LEFT(A5, 10), "PCO-R0343-"),  ISNUMBER(-MID(A5, ROW(INDIRECT("11:14")), 1))),
    AND(LEN(A5)=15, EXACT(LEFT(A5, 11), "DVCO-R0343-"), ISNUMBER(-MID(A5, ROW(INDIRECT("12:15")), 1))),
    AND(COUNTIF($A$5:$A$1005, "*-R0343-"&RIGHT(A5, 4))=1))

I expect you want

Code:
=AND(OR(AND(LEN(A5)=14, EXACT(LEFT(A5, 10), "PCO-R0343-"),  ISNUMBER(-MID(A5, ROW(INDIRECT("11:14")), 1))),
        AND(LEN(A5)=15, EXACT(LEFT(A5, 11), "DVCO-R0343-"), ISNUMBER(-MID(A5, ROW(INDIRECT("12:15")), 1)))),
     COUNTIF($A$5:$A$1005, "*-R0343-" & RIGHT(A5, 4))=1)
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,639
Members
449,325
Latest member
Hardey6ix

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