Wrapping IF ISERROR around INDEX function

折月煮酒 提交于 2020-01-07 09:18:29

问题


I have a problem with a dynamic list in Excel 2003 where some cells that I want to be empty are returning #NUM!. I have tried manipulating the following code, but to no avail:

=IF(ISERROR(INDEX(venue_name, SMALL(IF(($A$10=date_ns)*(COUNTIF($A$13:A29,venue_name)=0), ROW(date_ns)-MIN(ROW(date_ns))+1, ""), 1)))

I know its something to do with syntax/parentheses but have exhausted myself trying different combinations. Without the IF(ISERROR( and the closing bracket, the code runs absolutely fine.


回答1:


To use ISERROR you'd have to repeat the whole formula normally but presumably error is caused by an insufficient number of matching criteria so try this version in A14:

[Revised simpler version]

=IF(SUM(($A$10=date_ns)*(COUNTIF($A$13:A13,venue_name)=0)),INDEX(venue_name,MATCH(1,($A$10=date_ns)*(COUNTIF($A$13:A13,venue_name)=0),0)),"")

confirmed with CTRL+SHIFT+ENTER and copied down

....or you can use this version which doesn't need CTRL+SHIFT+ENTER

=IF(SUMPRODUCT(($A$10=date_ns)*(COUNTIF($A$13:A13,venue_name)=0)),INDEX(venue_name,MATCH(1,INDEX(($A$10=date_ns)*(COUNTIF($A$13:A13,venue_name)=0),0),0)),"")

see sample file here




回答2:


Seems to have been superseded by events but considering =ISERROR, as the maestro has said “you’d have to repeat the whole formula normally”. (Not necessary in later versions of Excel that have =IFERROR). Hence:

=IF(
ISERROR(
INDEX(venue_name, SMALL(IF(($A$10=date_ns)*(COUNTIF($A$13:A17,venue_name)=0), ROW(date_ns)-MIN(ROW(date_ns))+1, ""), 1))
)
,"",
INDEX(venue_name, SMALL(IF(($A$10=date_ns)*(COUNTIF($A$13:A17,venue_name)=0), ROW(date_ns)-MIN(ROW(date_ns))+1, ""), 1))
)  

the third and sixth lines (INDEX ...) are the 'working formula'. The first, fifth and last are the =IF condition (where a blank result is assumed to be required if TRUE). The second and fourth lines are the =ISERROR, which returns TRUE if an error is found (as a result of the 'working formula') and FALSE otherwise.

Could be represented as: =IF(error in working formula, blank, working formula).



来源:https://stackoverflow.com/questions/18229540/wrapping-if-iserror-around-index-function

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