如何在自定义数据验证中使用用户定义的函数? [英] How can using user defined function in custom data validation?
问题描述
在我的工作表中
我有一个表
并且想定义数据验证
包含日期的列,如下所示:
= S2M(B2)<>错误
在上面, S2M()
是一个用户自定义函数,用于将日期从波斯日期
转换为格里高利日期
,因为检查输入日期是正确的。 p>
但是excel不让我在Custom 数据验证
中使用用户定义的函数。
此错误显示:您指定的命名范围无法找到。
请注意,我在中使用命令范围$>
= AND(LEN(B2)= 10; ISNUMBER (IFERROR(VALUE(MATCH(VALUE(MID(B2; 1; 4)); INDIRECT( intTable [年]); 0)及MATCH(MID(B2; 6; 2); INDIRECT(intTable [芒斯];); 0)& MATCH(MID(B2; 9; 2); INDIRECT(intTable [Day]); 0)); FALSE)))
pre>
解释是波斯日期示例:1396/05/25
谢谢。
解决方案你可以这样做选择B2,或选择要应用验证的行2中的哪个单元格。现在定义一个叫做IsValid的名字,使用:
= S2M(B2)<>错误
现在在数据验证框中,您需要输入的所有内容是:
$在源框中的
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $并确保取消选中忽略空白选项。In my
Worksheet
I have aTable
and want to defineData validation
for a column that contained the date, as bellow:=S2M(B2)<>"Error"
In above,
S2M()
is a user defined function for converting date fromPersian date
toGregorian date
, because checking input date is right.But excel is not letting me use user defined functions in Custom
Data validation
.This error shows: A named range you specified cannot be found.
Please note that I was using bellow code in
Custom Data validation
and that works, right.=AND(LEN(B2)=10;ISNUMBER(IFERROR(VALUE(MATCH(VALUE(MID(B2;1;4));INDIRECT("intTable[Year]");0)&MATCH(MID(B2;6;2);INDIRECT("intTable[Mounth]");0)&MATCH(MID(B2;9;2);INDIRECT("intTable[Day]");0));FALSE)))
Explain is a Persian date example: 1396/05/25
Thanks.
解决方案You can do that. Select B2, or whichever cell in row 2 you want the validation to apply to. Now define a name called, say, IsValid, using:
=S2M(B2)<>"Error"
Now in the data validation box, all you need to enter is:
=IsValid
in the source box and make sure to uncheck the Ignore Blank option.
这篇关于如何在自定义数据验证中使用用户定义的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!