嵌套的公式与error handling
我有数据,并希望使用公式来确定安装的版本是x86还是x64:
OSTYPE SHORTPATH VERSION VERSIOND Microsoft Windows 7 Enterprise Edition, 64-bit C:\PROGRAM FILES (X86)\JAVA\JRE1.8.0_45\BIN\ 8.0.45.14 8.0.45.14 x86 Microsoft Windows 7 Enterprise Edition, 64-bit C:\PROGRAM FILES\JAVA\JRE1.8.0_66\BIN\ 8.0.660.18 8.0.660.18 x64 Microsoft Windows 7 Enterprise Edition, 32-bit C:\PROGRAM FILES\JAVA\JRE6\BIN\ 6.0.510.9 6.0.510.9 x86
意图是VERSIOND
将包含VERSION值,然后将x86
附加到32位安装或x64
位安装x64
。
If SHORTPATH contains "(x86)" then it's a 32bit install If SHORTPATH doesn't contain "(x86)" and OSTYPE contains "64-bit" then it's a 64bit install If SHORTPATH doesn't contain "(x86)" and OSTYPE contains "32-bit" then it's a 32bit install
我几乎已经通过:
=IF(ISERROR(SEARCH("(x86)";D2));IF(SEARCH("64-bit";C2)>0;CONCATENATE(E2;" x64");CONCATENATE(E2;" x86"));CONCATENATE(E2;" x86"))
C OSTYPE
,D SHORTPATH
,E SHORTPATH
VERSION
。
除了OSTYPE
是32位,它是有效的,这是因为SEARCH("64-bit";C2)>0
返回#VALUE!
“
如何添加第二个ISERROR来处理该错误?
较短的版本:
=E2&" "&IF(AND(ISERROR(SEARCH("x86";D2));NOT(ISERROR(SEARCH("64-bit";C2))));"x64";"x86")
假设如果SHORTPATH包含“(x86)”或者OSTYPE包含32位,那么您希望E列中的结果与“x86”连接,否则您希望将其与“x64”连接起来,您可以使用OR
来描述何时需要使用“x86”,甚至不明确search“64位”:
=IF(OR(NOT(ISERROR(SEARCH("(x86)",D2))),NOT(ISERROR(SEARCH("32-bit",C2)))),CONCATENATE(E2," x86"),CONCATENATE(E2," x64"))
以上是经过testing,但你似乎正在使用一个区域设置,使用;
代替,所以我想这将是:
=IF(OR(NOT(ISERROR(SEARCH("(x86)";D2)));NOT(ISERROR(SEARCH("32-bit";C2))));CONCATENATE(E2;" x86");CONCATENATE(E2;" x64"))