Does excel has a kind of a list formula?

I mean, suppose you have a kind of a hierarchy in colums A Containing all different kind a data. Than in column B you have data. Let's say that I would like to list the data from column A where there is an "X" in column B.

The list may be in seperate cells or just as a list in one cell.

I can think of a vlookup, but that would only give me one item, or a countif but that would not retieve the values from column A

Regards,

Shodan