Searching rows for two entries and returning the successful results (adapting existing code)

后端 未结 2 1593
情深已故
情深已故 2020-12-22 02:21

I am currently using this code in Excel to find and return, via an array, the results of a search but I need to adapt it to search based on two criteria instead of one and w

2条回答
  •  暖寄归人
    2020-12-22 02:48

    To add second condition to your search replace:

    =IF($B$1:$B$154="Good",ROW($B$1:$B$154)) 
    

    With

    =IF(($B$1:$B$154="Good")*($A$1:$A$154="Condition2"),ROW($B$1:$B$154))
    

    This part:

    ($B$1:$B$154="Good")*($A$1:$A$154="Condition2")
    

    Is an equivalent of:

    AND($B$1:$B$154="Good",$A$1:$A$154="Condition2")
    

    But AND often doesn't work well in array formulas (it returns single value).
    Another option is to use nested IF statement.

    If you are using Excel 2007 or later, you can also simplify your formula and instead of

    IF(ISERROR(INDEX(...),"",INDEX(...)))
    

    Use:

    IFERROR(INDEX(...),"")
    

提交回复
热议问题