Convert an Array Formula's Text Results into a Usable Format

前端 未结 5 1273
执念已碎
执念已碎 2020-12-04 01:36

When the results of an Array Formula are numbers, I find it generally easy to find an appropriate method to collapse the array into a single result. However when the results

5条回答
  •  無奈伤痛
    2020-12-04 02:10

    As stated previously, there is no native function which can do what you want in a single cell. If you absolutely cannot use VBA, then you could use a helper column (can hide the column if preferred) and then have the cell where you want the result simply show the last cell of the helper column.

    Example:

    Produce Name   Type
    Apple          Fruit
    Broccoli       Vegetable
    Carrot         Vegetable
    Orange         Fruit
    

    Say you want a single cell to show all Fruit results. You could use another column to host this formula. You will be hiding the column later, so let's use one out of the way, like column Z. We also want to easily be able to change what you're looking for, so we'll put the condition in cell D2. In cell Z2 and copied down, you would use this formula:

    =IF(B2=$D$2,IF(Z1="",A2,Z1&", "&A2),IF(Z1="","",Z1))
    

    That would result in the following:

    Produce Name   Type              Search For   (other columns until you get to Z)      
    Apple          Fruit             Fruit                                             Apple
    Broccoli       Vegetable                                                           Apple
    Carrot         Vegetable                                                           Apple
    Orange         Fruit                                                               Apple, Orange
    

    Then in wherever you want your result cell, we'll say D3, simply use this formula to get the last result from your helper column, and then hide the helper column.

    =Z5
    

    Which results in the following:

    Produce Name   Type              Search For
    Apple          Fruit             Fruit
    Broccoli       Vegetable         Apple, Orange
    Carrot         Vegetable
    Orange         Fruit
    

    You could use a dynamic named range instead of simply =Z5 to make sure you're always getting the last cell in your helper column so that your data can grow or shrink and you'll still get the correct result. But now you can change the contents of cell D2 from Fruit to be Vegetable and now the result cell will show Broccoli, Carrot. Hopefully something like this can be adapted to your needs.

提交回复
热议问题