Make possible combinations

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Using Excel 2000</SPAN></SPAN>

Hi,</SPAN></SPAN>

1st data in cells C6:E7, I need to get possible sets in the cells H6:O7</SPAN></SPAN>

2nd data in cells C9:E10, I need to get possible sets in the cells H9:O10 </SPAN></SPAN>

3rd data in cells C12:E13, I need to get possible sets in the cells H12:O13 </SPAN></SPAN>

And so on....</SPAN></SPAN>

Example sample data</SPAN></SPAN>

Book1
ABCDEFGHIJKLMNOPQR
1
2
3
4
5P1P2P3Set 1Set 2Set 3Set 4Set 5Set 6Set 7Set 8Set 9
61X1X
7222
8
9111
101X1X
11
12121122
131X1X1X
14
151X211XX22
16X2X2X2X2
17
181X1X
19XXX
20
21XXX
221X1X
23
24111
25X2X2
26
271X2111XXX222
281X21X21X21X2
29
30
Sheet1


Thank you in advance</SPAN></SPAN>

Regards</SPAN></SPAN>,</SPAN>
Kishan</SPAN></SPAN>
 
Last edited:

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG10Dec14
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac2 [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Lst [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
Lst = Range("C" & Rows.Count).End(xlUp).Row
[COLOR="Navy"]For[/COLOR] n = 6 To Lst
    c = 0
    [COLOR="Navy"]For[/COLOR] Ac = 3 To 6
        [COLOR="Navy"]For[/COLOR] Ac2 = 3 To 6
          [COLOR="Navy"]If[/COLOR] Not IsEmpty(Cells(n, Ac)) And Not IsEmpty(Cells(n + 1, Ac2)) [COLOR="Navy"]Then[/COLOR]
             c = c + 1
                Cells(n, c + 7) = Cells(n, Ac)
                Cells(n + 1, c + 7) = Cells(n + 1, Ac2)
           [COLOR="Navy"]End[/COLOR] If
        [COLOR="Navy"]Next[/COLOR] Ac2
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this:-
Code:
[COLOR=navy]Sub[/COLOR] MG10Dec14
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, Ac [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Ac2 [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] n [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] c [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Dim[/COLOR] Lst [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
Lst = Range("C" & Rows.Count).End(xlUp).Row
[COLOR=navy]For[/COLOR] n = 6 To Lst
    c = 0
    [COLOR=navy]For[/COLOR] Ac = 3 To 6
        [COLOR=navy]For[/COLOR] Ac2 = 3 To 6
          [COLOR=navy]If[/COLOR] Not IsEmpty(Cells(n, Ac)) And Not IsEmpty(Cells(n + 1, Ac2)) [COLOR=navy]Then[/COLOR]
             c = c + 1
                Cells(n, c + 7) = Cells(n, Ac)
                Cells(n + 1, c + 7) = Cells(n + 1, Ac2)
           [COLOR=navy]End[/COLOR] If
        [COLOR=navy]Next[/COLOR] Ac2
    [COLOR=navy]Next[/COLOR] Ac
[COLOR=navy]Next[/COLOR] n
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
MickG, your coding is unique!! It worked ideal with example layout, even it is working if I delete empty rows in-between each set or double them perfect!!</SPAN></SPAN>

Thank you for your time and help
</SPAN></SPAN>

Kind Regards,
</SPAN>
Kishan
</SPAN></SPAN>:biggrin:
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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