user3011084
user3011084

Reputation: 133

Match function in excel

suppose I have this table in excel:

enter image description here

And I want to use match function to find the value 5:

MATCH(5,B2:B5,0)

How I can return both values in B2 and B4

Upvotes: 0

Views: 33

Answers (1)

Scott Craner
Scott Craner

Reputation: 152450

Use TEXTJOIN():

=TEXTJOIN(", ",TRUE,FILTER((ROW($B$2:$B$5)-MIN(ROW($B$2:$B$5))+1),$B$2:$B$5=5,""))

or in Excel 2019

=TEXTJOIN(", ",TRUE,IF($B$2:$B$5=5,(ROW($B$2:$B$5)-MIN(ROW($B$2:$B$5))+1),""))

Depending on one's version this may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

enter image description here


But my guess is that this is only a step to get what you really want, to return the value in column A where it is 5:

=TEXTJOIN(", ",TRUE,FILTER($A$2:$A$5,$B$2:$B$5=5,""))

2019:

=TEXTJOIN(", ",TRUE,IF($B$2:$B$5=5,$A$2:$A$5,""))

Depending on one's version this may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.

enter image description here

Upvotes: 1

Related Questions