MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 20th, 2002, 04:14 AM   #1
verluc
Board Regular
 
Join Date: Mar 2002
Posts: 1,288
Default

Can someone advise me for a macro that can produce a list that contains all
possible combinations of 6 from 27
Thanks in advance
verluc is offline   Reply With Quote
Old May 20th, 2002, 06:33 AM   #2
s-o-s
Board Regular
 
s-o-s's Avatar
 
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
Default

Quote:
On 2002-05-20 03:14, verluc wrote:
Can someone advise me for a macro that can produce a list that contains all
possible combinations of 6 from 27
Thanks in advance
If my old stats knowledge is correct,
Code:
27
  C  =  296,010 combinations
   6
In which case you will have to write your list to a non excel sheet.

Is this what you want to do?




__________________
Hope This Helps.
Sean.
Digest of Homes

WinXP, XL XP
s-o-s is offline   Reply With Quote
Old May 20th, 2002, 06:40 AM   #3
ldry
New Member
 
Join Date: Apr 2002
Posts: 8
Default

An Excel sheet has plenty of room - 16,777,216 cells
ldry is offline   Reply With Quote
Old May 20th, 2002, 06:53 AM   #4
s-o-s
Board Regular
 
s-o-s's Avatar
 
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
Default

Quote:
On 2002-05-20 05:40, ldry wrote:
An Excel sheet has plenty of room - 16,777,216 cells
A very good point, I was thinking of a verticle list. At 65000 rows it will jump across 1 column

Here's the code...Its not the best but it works!


Code:
Code has been deleted as it didn't work, 

It had duplication in it...now replaced...

See below.
Hope this helps


_________________






[ This Message was edited by: s-o-s on 2002-05-20 09:11 ]
s-o-s is offline   Reply With Quote
Old May 20th, 2002, 07:12 AM   #5
s-o-s
Board Regular
 
s-o-s's Avatar
 
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
Default

I've found some duplication eg cell
C 21802 has

1 4 3 4 5 6

I'll have a bit more of a think...
s-o-s is offline   Reply With Quote
Old May 20th, 2002, 07:27 AM   #6
s-o-s
Board Regular
 
s-o-s's Avatar
 
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
Default

Think I've got it this time...Send me an email if you find it doesn't work this time as I will be going off line...

Code:
Sub Combs()
Application.ScreenUpdating = False
rw = 1
cl = 0
For a = 1 To 27
    For b = (a + 1) To 27
        For c = (b + 1) To 27
            For d = (c + 1) To 27
                For e = (d + 1) To 27
                    For f = (e + 1) To 27

' Place in here the code to write your list
' what goes in here depends on how you want to export

                    If rw >= 65000 Then
                        Application.ScreenUpdating = True
                        rw = 1
                        cl = cl + 1
                        Application.ScreenUpdating = False
                    End If
                    cellval = a & " " & b & " " & c & " " & d & " " & e & " " & f
                    Range("A1").Offset(rw, cl).Value = cellval
                    rw = rw + 1
                    Next
                Next

            Next
        Next
    Next
Next
Application.ScreenUpdating = True
End Sub
Hope It works this time.


__________________
Hope This Helps.
Sean.
Digest of Homes

WinXP, XL XP
s-o-s is offline   Reply With Quote
Old May 20th, 2002, 07:28 AM   #7
verluc
Board Regular
 
Join Date: Mar 2002
Posts: 1,288
Default

Quote:
On 2002-05-20 05:53, s-o-s wrote:
Quote:
On 2002-05-20 05:40, ldry wrote:
An Excel sheet has plenty of room - 16,777,216 cells
A very good point, I was thinking of a verticle list. At 65000 rows it will jump across 1 column

Here's the code...Its not the best but it works!


Code:
Sub Combs()
application.ScreenUpdating = False
rw = 1
cl = 0
For a = 1 To 27
    For b = 2 To 27
        For c = 3 To 27
            For d = 4 To 27
                For e = 5 To 27
                    For f = 6 To 27
                        If f = e Then GoTo Eloop6
                        If f = d Then GoTo Eloop6
                        If f = c Then GoTo Eloop6
                        If f = b Then GoTo Eloop6
                        If f = a Then GoTo Eloop6

' Place in here the code to write your list
' what goes in here depends on how you want to export
                    If rw > 65000 Then
                        rw = 1
                        cl = cl + 1
                    End If
                    cellval = a & " " & b & " " & c & " " & d & " " & e & " " & f
                    Range("A1").Offset(rw, cl).Value = cellval
                    rw = rw + 1
Eloop6:
                    Next
                    If e = d Then GoTo Eloop5
                    If e = c Then GoTo Eloop5
                    If e = b Then GoTo Eloop5
                    If e = a Then GoTo Eloop5
Eloop5:
                Next
                If d = c Then GoTo Eloop4
                If d = b Then GoTo Eloop4
                If d = a Then GoTo Eloop4
Eloop4:
            Next
            If c = b Then GoTo Eloop3
            If c = a Then GoTo Eloop3

Eloop3:
        Next
        If b = a Then GoTo Eloop2
Eloop2:
    Next
Next
application.ScreenUpdating = True
End Sub
Hope this helps



ps forgot to add back in the updating screen options...now edited successfully.

_________________





[ This Message was edited by: s-o-s on 2002-05-20 06:00 ]
Hi,
Thanks for your macro.When I run it,then all
the numbers are in 1 column.
Is it possible that all numbers are in different columns.Example: A B C D E F
Thanks in advance/
verluc is offline   Reply With Quote
Old May 20th, 2002, 08:06 AM   #8
s-o-s
Board Regular
 
s-o-s's Avatar
 
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
Default

OK, here's the code for that one...

Code:
Sub Combs2()
Application.ScreenUpdating = False
rw = 1
cl = 0
For a = 1 To 27
    For b = (a + 1) To 27
        For c = (b + 1) To 27
            For d = (c + 1) To 27
                For e = (d + 1) To 27
                    For f = (e + 1) To 27

                    If rw >= 65000 Then
                        Application.ScreenUpdating = True
                        rw = 1
                        cl = cl + 10
                        Application.ScreenUpdating = False
                    End If
                    cellval = a & " " & b & " " & c & " " & d & " " & e & " " & f
                    
                    Range("A1").Offset(rw, cl).Value = a
                    Range("A1").Offset(rw, cl + 1).Value = b
                    Range("A1").Offset(rw, cl + 2).Value = c
                    Range("A1").Offset(rw, cl + 3).Value = d
                    Range("A1").Offset(rw, cl + 4).Value = e
                    Range("A1").Offset(rw, cl + 5).Value = f
                    rw = rw + 1
                    Next
                Next

            Next
        Next
    Next
Next
Application.ScreenUpdating = True
End Sub
Hope this helps.


__________________
Hope This Helps.
Sean.
Digest of Homes

WinXP, XL XP
s-o-s is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:18 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes