vba 如果此公式中没有值,如何返回空白而不是 #N/A?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40348691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I return a blank instead of #N/A if there is no value in this formula?
提问by thisguyAgain
I'm looking for a value in a range and returning the value base on user selected value. The value returns correctly if there is a match but when there is no match, it returns #N/A. How do I return blank or something else other than #N/A?
我正在寻找一个范围内的值并根据用户选择的值返回该值。如果匹配,则该值正确返回,但不匹配时,则返回 #N/A。我如何返回空白或 #N/A 以外的其他内容?
=INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0))
回答by BruceWayne
You can wrap that in IfError()
:
您可以将其包装在IfError()
:
=IfError(INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0)),"")
=IfError(INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0)),"")
Or if you don't have IfError()
:
或者,如果您没有IfError()
:
=If(IsErr(INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0)),"",INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0)))
=If(IsErr(INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0)),"",INDEX(AB4:AB14,MATCH(P26,AA4:AA14,0)))