Hi all!
I usually lurk in these forums for all my VBA questions. There are several real nuggets of advice and solutions. I am always able to combine code and learn of the solutions offered. However, I can't get the following problem fixed... Basically I got a dynamic amount of columns in one sheet. I want to compare all possible combinations of columns in a separate sheet. So if I got Column A t/m F on the main sheet, I want a sheet for column A & B, one sheet for A & C, one sheet for A & D, etc... until the last sheet that consists of E & F.
[TABLE="width: 954"]
<tbody>[TR]
[TD="colspan: 2"]Main sheet:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet 1:[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet 2:[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet 3:[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ColumnA[/TD]
[TD]ColumnB[/TD]
[TD]ColumnC[/TD]
[TD]ColumnD[/TD]
[TD]ColumnE[/TD]
[TD]ColumnF[/TD]
[TD][/TD]
[TD]ColumnA[/TD]
[TD]ColumnB[/TD]
[TD][/TD]
[TD]ColumnA[/TD]
[TD]ColumnC[/TD]
[TD][/TD]
[TD]ColumnA[/TD]
[TD]ColumnD[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]16[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]16[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD="align: right"]11[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]16[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]12[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[/TR]
[TR]
[TD="align: right"]18[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]19[/TD]
[/TR]
[TR]
[TD="align: right"]19[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]14[/TD]
[TD][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]2[/TD]
[/TR]
</tbody>[/TABLE]
The issue is that the amount of columns is dynamic. So sometimes its 10, sometimes 15 and it can run up to 20. I am currently struggling to get it done with a double column loop, but I think I am thinking in the wrong direction.
Is there anyone who can give me a push in the right direction ?
Thanks in advance,
Koen
I usually lurk in these forums for all my VBA questions. There are several real nuggets of advice and solutions. I am always able to combine code and learn of the solutions offered. However, I can't get the following problem fixed... Basically I got a dynamic amount of columns in one sheet. I want to compare all possible combinations of columns in a separate sheet. So if I got Column A t/m F on the main sheet, I want a sheet for column A & B, one sheet for A & C, one sheet for A & D, etc... until the last sheet that consists of E & F.
[TABLE="width: 954"]
<tbody>[TR]
[TD="colspan: 2"]Main sheet:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet 1:[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet 2:[/TD]
[TD][/TD]
[TD][/TD]
[TD]Sheet 3:[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]ColumnA[/TD]
[TD]ColumnB[/TD]
[TD]ColumnC[/TD]
[TD]ColumnD[/TD]
[TD]ColumnE[/TD]
[TD]ColumnF[/TD]
[TD][/TD]
[TD]ColumnA[/TD]
[TD]ColumnB[/TD]
[TD][/TD]
[TD]ColumnA[/TD]
[TD]ColumnC[/TD]
[TD][/TD]
[TD]ColumnA[/TD]
[TD]ColumnD[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]12[/TD]
[/TR]
[TR]
[TD="align: right"]8[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]4[/TD]
[TD][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]16[/TD]
[/TR]
[TR]
[TD="align: right"]13[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]16[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD="align: right"]11[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]19[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]16[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]10[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]6[/TD]
[TD][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]20[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]8[/TD]
[/TR]
[TR]
[TD="align: right"]16[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]12[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]20[/TD]
[TD="align: right"]11[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]5[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]12[/TD]
[TD][/TD]
[TD="align: right"]16[/TD]
[TD="align: right"]17[/TD]
[/TR]
[TR]
[TD="align: right"]18[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]13[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]13[/TD]
[TD][/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]17[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]6[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]17[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]6[/TD]
[/TR]
[TR]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]3[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]9[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]3[/TD]
[TD][/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD="align: right"]10[/TD]
[TD="align: right"]8[/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]8[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]15[/TD]
[TD][/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]14[/TD]
[/TR]
[TR]
[TD="align: right"]15[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]18[/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]1[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]18[/TD]
[TD][/TD]
[TD="align: right"]15[/TD]
[TD="align: right"]19[/TD]
[/TR]
[TR]
[TD="align: right"]19[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]14[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]10[/TD]
[TD][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]7[/TD]
[TD][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]14[/TD]
[TD][/TD]
[TD="align: right"]19[/TD]
[TD="align: right"]2[/TD]
[/TR]
</tbody>[/TABLE]
The issue is that the amount of columns is dynamic. So sometimes its 10, sometimes 15 and it can run up to 20. I am currently struggling to get it done with a double column loop, but I think I am thinking in the wrong direction.
Is there anyone who can give me a push in the right direction ?
Thanks in advance,
Koen