Column number where all values match

cs56lioy

New Member
Joined
Dec 9, 2024
Messages
6
Office Version
  1. 2021
Platform
  1. Windows
Given this array
Excel Formula:
{0,1,0,0;0,1,0,0}
I would like to return the number 2 for the column number where both rows contain a 1.
I tried
Excel Formula:
XMATCH(1,{0,1,0,0;0,1,0,0},0)
and even
Excel Formula:
XMATCH({1;1},{0,1,0,0;0,1,0,0},0)
but none of them worked.

Any help would be appreciated
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Is this what you mean ?


01000100
22


If so

=IF(--(B3:I3=1),2,"")
 
Upvote 0
It is more like
0100
0100
You can see that the 2nd. column has the 1's, so I need the number of the column that has both 1's returned
 
Upvote 0
Try
Excel Formula:
=XMATCH(TRUE,MMULT({1,1},{0,1,0,0;0,1,0,0})=2)
 
Last edited:
Upvote 1
Solution
Apologies for the delay was called away, I'm sure Cubist formula does what you need (going by help I have received on previous posts his excel knowledge is far superior than mine!) Just curious are the 1's always in the second column or could you have 1's in different columns ?

If so you could try the below that will give you anything that has multiple "1"'s across various columns (If I've understood what you mean).

Adjust ranges to suit

=IF(SUM(C3:C22)>=2,COLUMN(),"")

357
01000100
01010100
01010100
 
Upvote 0
I'm assuming you aren't actually using a hard-coded array, so along the line of what Arts is suggesting:

=MATCH(2,A1:D1+A2:D2,0)
 
Upvote 0
Thanks Cubist. That worked.

Thanks Arts for you help.
To clarify, the array has 2 rows and I am looking for the column that has a 1 in both rows. There could be 1's elsewhere. Nothing is hardcoded, other than that there are 2 rows.
 
Upvote 0
Just for the record, the following also worked
Excel Formula:
=XMATCH(TRUE,1&1={0,1,0,0}&{0,1,0,0},0)
 
Upvote 0

Forum statistics

Threads
1,224,740
Messages
6,180,678
Members
452,993
Latest member
FDARYABEE

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