Copy and Paste Binary Matrix Values in a specific order with FORMULA or VBA

DaveMars

New Member
Joined
Oct 16, 2017
Messages
3
Hello,

this is my first thread but I have been reading and learning since months if not years.

Now I'm stuck with this problem and I can't find a solution on my own.

I have a binary table like this:

ABCD
16C0100
51C0010
17A0001
39A0100
24C0001
16A0010
26C1000
27A0010
33A0100
12C0001
20C1000

<tbody>
</tbody>

And I'd like to build an output table which tells me, for each column header, the row label which is =1.

The number of occurences of 1 for each column is <= 3, so I would like to get for each column, at max, the first three labels which have 1 in the matrix.

Example:

ABCD
26C16C51C17A
20C39A16A24C
33A27A12C

<tbody>
</tbody>

I've tried with:

- Nested IF
- SMALL function
- MATCH
- INDEX

but I really can't figure out a solution.

Could you please help me?

Thank you
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
This matrix formula seems to do the trick:
Code:
=IFERROR(INDEX($A$2:$A$12,SMALL(IF(B$2:B$12=1,ROW(B$2:B$12)-1,90),{1;2;3})),"")
Select three cells beneath each other and enter the formula using control+shift+enter. Then copy to the right.
 
Last edited:
Upvote 0
Thank you for answering, but I'm getting an error and excel highlights this part of the formula:

$A$12,SMALL

I don't know if I'm doing something wrong or how to correct.

Could you please help me?
 
Upvote 0
Replacing all comma's in the formula I gave with semi-colons ; will probably help.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,935
Members
449,195
Latest member
Stevenciu

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