custom data validation in Excel for alpha-numeric-alpha value

我与影子孤独终老i 提交于 2019-12-13 20:06:39

问题


I want to force users to enter data in a specific cell in a sequence like ABCDE1234F

i.e. first five characters must me letters then four digits and last must be a letter using custom data validation.


回答1:


It is quite long:

=AND(ISNUMBER(SUMPRODUCT(SEARCH("~"&MID(A1,ROW($1:$5),1),"abcdefghijklmnopqrstuvwxyz"))),ISNUMBER(SUMPRODUCT(SEARCH("~"&MID(A1,ROW($6:$9),1),"0123456789"))),ISNUMBER(SUMPRODUCT(SEARCH("~"&MID(A1,10,1),"abcdefghijklmnopqrstuvwxyz"))),LEN(A1)=10)

It goes through each of the required text characters and checks if it is a number or a string. Then it test the full range of numbers for text. It also ensures that it is ten characters long.




回答2:


You may try following formula

=AND(ISTEXT(LEFT(A1,5)),ISNUMBER(MID(A1,6,4)*1),ISTEXT(MID(A1,10,1)),IF(LEN(A1)=10,TRUE,FALSE))


来源:https://stackoverflow.com/questions/35243555/custom-data-validation-in-excel-for-alpha-numeric-alpha-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!