How can I use MATCH for multiple rows and get a spill?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

Suppose I have an array as shown in the attached XL2BB, and I want to spill the positions of the cells that have the value of say 34. MATCH takes only 1D arrays, so I was trying to use MAP, but I couldn't get it to work 🤓 It seems that MAP only takes functions that take 2D arrays?

Blank power workbook1
ABCDEFGHIJKL
1
2desired output
3449934827377#N/A3
45684643469384
55734365338132
622301003461544
79616257910346
83790203419544
91712365115346
105347133434434
113433727953541
12
Sheet2
Cell Formulas
RangeFormula
I3I3=MATCH(34,B3:G11,0)


Thanks for any input! 🤗
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I don't have BYROW on my PC, so I can't test this, but you might want to try BYROW:

Excel Formula:
=BYROW(B3:G11, LAMBDA(array, MATCH(34,array,0)))
 
Upvote 0
Solution
@Eric W Ah right, I completely forgot about BYROW. It works very well. Thanks!

@hajiali Thanks. I knew about the dragging down, but I was looking for a spill formula.
 
Upvote 0
Try. In I3
Excel Formula:
=MMULT(IF(B3:G11=C1,COLUMN(B3:G11)-COLUMN(A1),0),TRANSPOSE(1*(COLUMN(B3:G3)>0)))
If there is no match formula returns 0.
 
Upvote 0
Awesome, thanks! This can be helpful in more complex functions that BYROW may not like. I changed your function like this:

Excel Formula:
=LET(r,B3:G11,l,34,x,COLUMN(r),MMULT(IF(r=l,x-MIN(x)+1,0),SEQUENCE(COLUMNS(r),,1,0)))
 
Upvote 0
Just a thought - the latest MMULT formulas have a potential issue if there is more than one matching value on a given row. For example, row 10:

Book1
ABCDEFGHIJK
134
2kvsrinivasamurthyRnkhchEric W
3449934827377333
4568464346938444
5573436533813222
62230100346154444
7961625791034666
8379020341954444
9171236511534666
10534713343443994
11343372795354111
Sheet1
Cell Formulas
RangeFormula
I3:I11I3=MMULT(IF(B3:G11=C1,COLUMN(B3:G11)-COLUMN(A1),0),TRANSPOSE(1*(COLUMN(B3:G3)>0)))
J3:J11J3=LET(r,B3:G11,l,34,x,COLUMN(r),MMULT(IF(r=l,x-MIN(x)+1,0),SEQUENCE(COLUMNS(r),,1,0)))
K3:K11K3=LET(rng,B3:G11,v,34,sa,SEQUENCE(ROWS(rng),,0),sb,SEQUENCE(,COLUMNS(rng)),sc,TRANSPOSE(sb),MMULT((rng=v)*(COUNTIF(OFFSET(rng,sa,0,1,sb),v)=1),sc))
Dynamic array formulas.


I found a way to return the value of the first matching column, instead of the sum of the matching columns. It's pretty unwieldy though.
 
Upvote 0
Thank you so much Eric for catching that! 🤗 And great formula!
 
Upvote 0

Forum statistics

Threads
1,216,051
Messages
6,128,505
Members
449,455
Latest member
jesski

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