A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
You may already be 3/4 of the way there:
=TEXTSPLIT(TEXTJOIN(",",TRUE,IF(--((A1:E5=G1)+(A1:E5=H1)),A1:E5,"")),",")
If you want the result to list vertically:
=TOCOL(TEXTSPLIT(TEXTJOIN(",",TRUE,IF(--((A1:E5=G1)+(A1:E5=H1)),A1:E5,"")),","))