Macro for counting interactions between individuals

BioPA

New Member
Joined
Oct 26, 2013
Messages
30
Hi!

Needless to say how grateful i am to you for replying to my questions 6 months ago.

Could you give your lights again?

Assuming that i want to count how many times an individual says ''thanks'' :) to his colleagues. So, we have the table below:
FromTo
AB
CA
DA
CA
EB
......

<tbody>
</tbody>

Is it possible to have a macro that it will search the number of interactions from the two columns and will give us all the possible combinations with a new table such as below? (including the ''rude'' zero interactions)

FromToSum
AB1
AC0
AD0
AE0
BA0
BC0
BD0
BE0
CA2
CB0
CD0
.........

<tbody>
</tbody>

BioPaMr.Excel Members1000:):)

<tbody>
</tbody>
 
Yes, sure. Here it is for 3 combinations (well, being created automatically, the spreadsheet displays a certain degree of redundancy, repeating the same formulas several times).


Excel 2010
ABCDEFGHIJKLMNOP
1A33AA39AAA2711AAA
2BABAAB104ABA
3CACAAC197ACA
4BAABA210BAA
5BBABB1113BBA
6BCABC2016BCA
7CAACA319CAA
8CBACB1222CBA
9CCACC2125CCA
10#N/A#N/ABAA42AAB
11#N/A#N/ABAB135ABB
12#N/A#N/ABAC228ACB
13#N/A#N/ABBA511BAB
14#N/A#N/ABBB1414BBB
15#N/A#N/ABBC2317BCB
16#N/A#N/ABCA620CAB
17#N/A#N/ABCB1523CBB
18#N/A#N/ABCC2426CCB
19#N/A#N/ACAA73AAC
20#N/A#N/ACAB166ABC
21#N/A#N/ACAC259ACC
22#N/A#N/ACBA812BAC
23#N/A#N/ACBB1715BBC
24#N/A#N/ACBC2618BCC
25#N/A#N/ACCA921CAC
26#N/A#N/ACCB1824CBC
27#N/A#N/ACCC2727CCC
RelAlg result
Cell Formulas
RangeFormula
B1=COUNTA(A:A)-COUNTIFS(A:A,NA())
C1=COUNTA(A:A)-COUNTIFS(A:A,NA())
D1=IF(ROW()>$B$1*$C$1,NA(),INDEX(A:A,QUOTIENT(ROW()-1,$B$1)+1))
D2=IF(ROW()>$B$1*$C$1,NA(),INDEX(A:A,QUOTIENT(ROW()-1,$B$1)+1))
E1=IF(ISNA($D1),NA(),INDEX(A:A,MOD(ROW()-1,$B$1)+1))
E2=IF(ISNA($D2),NA(),INDEX(A:A,MOD(ROW()-1,$B$1)+1))
F1=COUNTA(A:A)-COUNTIFS(A:A,NA())
G1=COUNTA(D:D)-COUNTIFS(D:D,NA())
H1=IF(ROW()>$F$1*$G$1,NA(),INDEX(D:D,QUOTIENT(ROW()-1,$F$1)+1))
H2=IF(ROW()>$F$1*$G$1,NA(),INDEX(D:D,QUOTIENT(ROW()-1,$F$1)+1))
I1=IF(ROW()>$F$1*$G$1,NA(),INDEX(E:E,QUOTIENT(ROW()-1,$F$1)+1))
I2=IF(ROW()>$F$1*$G$1,NA(),INDEX(E:E,QUOTIENT(ROW()-1,$F$1)+1))
J1=IF(ISNA($H1),NA(),INDEX(A:A,MOD(ROW()-1,$F$1)+1))
J2=IF(ISNA($H2),NA(),INDEX(A:A,MOD(ROW()-1,$F$1)+1))
K1=COUNTA($J:$J)-COUNTIFS($J:$J,NA())
L1=IF(ISNA($J1),$K$1+1,IF(ISERR($J1),1+$K$1-COUNTIFS($J:$J,$J1),COUNTIFS($J:$J,"<"&$J1)+COUNTIFS($J$1:$J1,$J1)))
L2=IF(ISNA($J2),$K$1+1,IF(ISERR($J2),1+$K$1-COUNTIFS($J:$J,$J2),COUNTIFS($J:$J,"<"&$J2)+COUNTIFS($J$1:$J2,$J2)))
M1=MATCH(ROW(),$L:$L,0)
M2=MATCH(ROW(),$L:$L,0)
N1=INDEX(H:H,$M1)
N2=INDEX(H:H,$M2)
O1=INDEX(I:I,$M1)
O2=INDEX(I:I,$M2)
P1=INDEX(J:J,$M1)
P2=INDEX(J:J,$M2)
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,215,217
Messages
6,123,670
Members
449,115
Latest member
punka6

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