我创建了一个限制输入到单元格的公式,创建的公式如下:
=AND(FIND("-",F5,1)=3,1*LEFT(F5,FIND("-",F5,1)-1)<13,1*LEFT(F5,FIND("-",F5,1)-1)>=1,ISNUMBER(1*RIGHT(F5,LEN(F5)-FIND("-",F5,1))))
我的发票号码格式为:“00-000”,公式可以防止给出任何字母输入。我想要做的是启用右侧部分的字母输入(000)。
答案 0 :(得分:0)
如果您的输入仅包含字母,数字和连字符,则此公式为TRUE
:
=(SUMPRODUCT(LEN(SUBSTITUTE(UPPER(F5),{"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","-","0","1","2","3","4","5","6","7","8","9"},"")))=36*LEN(F5))
使用SUMPRODUCT
查找输入的长度(UPPER(F5)
),每个37个字符"A"-"Z"
:26 + "0"-"9"
:10 + {{1 1)并将它们添加到一起。如果字符串中的每个字符已被替换一次(即它们都在37的列表中),则此总长度将 36 乘以原始字符串的长度(每个角色在未被替换的36次中每次出现一次)
要添加/删除有效字符,请在{Array}中添加/删除它们,然后将"-"
向上或向下调整为比您接受的字符数少1。