![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Can someone advise me for a macro that can produce a list that contains all
possible combinations of 6 from 27 Thanks in advance |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
Quote:
Code:
27 C = 296,010 combinations 6 Is this what you want to do?
__________________
Hope This Helps. Sean. Digest of Homes WinXP, XL XP |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 8
|
An Excel sheet has plenty of room - 16,777,216 cells
|
|
|
|
|
|
#4 | |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
Quote:
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. _________________ ![]() [ This Message was edited by: s-o-s on 2002-05-20 09:11 ] |
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
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... |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
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 This Helps. Sean. Digest of Homes WinXP, XL XP |
|
|
|
|
|
#7 | ||
|
Board Regular
Join Date: Mar 2002
Posts: 1,288
|
Quote:
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/ |
||
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
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. Sean. Digest of Homes WinXP, XL XP |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|