I have written a formula to do data validation that an five character batch code complies to the format "A1234", however is seems a bit long winded and wonder if anyone can suggest a more streamlined solution - must not involve arrays unfortunately.
In position 1, The first character must comply with a list of legal letters(only upper case allowed)in named range rngAplha
ABCDEFGHKLMNPQRSTUVWX
The numbers in positions 2 to 5 must all be integers, no decimals, with the allowable values of the four numbers are from 0001 to 9999.
This formula works:
Brief functional description:
IFERRORIFERROR (AND(1,2,3,4,5), "Batch No. error")
AND 1LEN(G3)=5
AND 2IF(COUNTIF(rngAlpha,LEFT(G3,1))=1,EXACT(LEFT(G3,1),UPPER(LEFT(G3,1))))
AND 3INT(RIGHT(G3,4))=RIGHT(G3,4)*1
AND 4RIGHT(G3,4)*1>0
AND 5ISERR(SEARCH(".",G3,1))
The numbers are the biggest problem, individually and as a string.
Thanks in advance for your creative responses!
Mark
In position 1, The first character must comply with a list of legal letters(only upper case allowed)in named range rngAplha
ABCDEFGHKLMNPQRSTUVWX
The numbers in positions 2 to 5 must all be integers, no decimals, with the allowable values of the four numbers are from 0001 to 9999.
This formula works:
Code:
=IFERROR(AND(LEN(C3)=5,IF(COUNTIF(rngAlpha,LEFT(C3,1))=1,EXACT(LEFT(C3,1),UPPER(LEFT(C3,1)))),INT(RIGHT(C3,4))=RIGHT(C3,4)*1,RIGHT(C3,4)*1>0),"Batch No. error")
Brief functional description:
IFERRORIFERROR (AND(1,2,3,4,5), "Batch No. error")
AND 1LEN(G3)=5
AND 2IF(COUNTIF(rngAlpha,LEFT(G3,1))=1,EXACT(LEFT(G3,1),UPPER(LEFT(G3,1))))
AND 3INT(RIGHT(G3,4))=RIGHT(G3,4)*1
AND 4RIGHT(G3,4)*1>0
AND 5ISERR(SEARCH(".",G3,1))
The numbers are the biggest problem, individually and as a string.
Thanks in advance for your creative responses!
Mark