How To Return A Row Of Values If A Value Is Found Anywhere In That Row

excelbytes

Active Member
Joined
Dec 11, 2014
Messages
252
Office Version
  1. 365
Platform
  1. Windows
In the example in the image attached, I want to search anywhere in columns D1:J106 for the values listed in column L and if that value is found anywhere in D1:J106, list the values starting in column M. The example I am showing that's highlighted if value 240 in L13. It is found in cell E10, so the values from D10:J10 are listed in M13:S13.
Screenshot 2024-05-09 170319.png
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try:

Book1
DEFGHIJKLMNOP
1Column 1Column 2Column 3Column 4Column 5Column 6Column 7Value
2557314201 
3324904203 
4220740205 
5223717208 
6224847210 
7226382548519212332646917212
8234330214 
9236672778604250215267445215
10227240301217447217
11249705224224847
12267445215234234330
13272570240227240301
14279916248 
15281346832713256 
16289365905267267445215
17321407270 
18323213281281346832713
19326937301227240301
20331630303 
21332646917212304 
22339781305 
23341510310424310
24343613312 
25347929718314557314
26351978315 
27364570321321407
28367581418323323213
29368587825780403330234330
30380614331331630
31385801336 
32424310347347929718
33430903360 
34431204385385801
35437647416402 
36438514404 
37442760405 
38443667410407321407
39447217408 
40448850410443667410
41458541412 
Sheet1
Cell Formulas
RangeFormula
M2:M6,M8,M14:M15,M17,M20:M22,M24,M26,M31,M33,M35:M37,M39,M41,M40:S40,M38:S38,M34:S34,M32:S32,M27:S30,M25:S25,M23:S23,M18:S19,M16:S16,M9:S13,M7:S7M2=LET(t,$D$2:$J$41,m,MAX(IF(L2=t,ROW(t)-ROW(INDEX(t,1,1))+1)),IF(m=0,"",INDEX(t,m,0)&""))
 
Upvote 0
Solution
Another approach:
Excel Formula:
=LET(a,$D$2:$J$41,IFERROR(INDEX(a,MATCH(1,SIGN(MMULT(--(L2=a),{1;1;1;1;1;1;1})),0),0)&"",""))
Note: this formula returns the row with the first occurrence of, say, 570, whereas formula from Post #2 returns the row with the last occurrence.
 
Upvote 0
Another option, that will return the 1st occurrence.
Excel Formula:
=LET(a,TAKE(FILTER($D$2:$J$100,BYROW($D$2:$J$100,LAMBDA(br,COUNTIFS(br,L2))),""),1),IF(a="","",a))
 
Upvote 0
I managed to shorten my formula a bit:

Excel Formula:
=LET(t,$D$2:$J$41,m,MAX(IF(L2=t,ROW(t)-MIN(ROW(t))+1)),IF(m,INDEX(t,m,0)&"",""))

Also, I suspect these are North American area codes. Each row has the codes for a specific state/province/region. If so, there will only be 1 occurrence of each number.
 
Upvote 0

Forum statistics

Threads
1,216,143
Messages
6,129,110
Members
449,486
Latest member
malcolmlyle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top