Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Creating character combinations out of a possible set...

...every possible combination is displayed.

Hi. As others have mention, the output is too large.
A newer measure of large might be that you would have to completely fill
3,486,784,401 Columns in Excel 2007. (36^10/2^20) <vbg
In Combinations, one is usually not interested in generating all
combinations. One is usually interested in generating only a few of the
outputs. One might be interested in the 1 millionth item in the list, or
perhaps pick a few items from the list at Random.
It is usually more efficient to generate the combinations as needed. The
function name usually goes by the name UnRank...(ie UnRankCombinations, or
something similar for your example)

The code below just demo's how this might be done for your 3 character
example.
Excel vba can easily find the 2456158341262976 th item from your 10
character example, but it requires a little modification.

Again, this is just a simple example...

Sub TestIt()
Debug.Print UnRank(1) 'First item in list
Debug.Print UnRank(46656)'Last item in list
Debug.Print UnRank(1372)' the 1372 th item in list
End Sub

Returns:
000
ZZZ
123

Function UnRank(Num As Double) As String
Dim n As Double
Dim Block As Double
Dim j As Long
Dim M As Double
Dim s(0 To 35) As String
Const k As Double = 36

For n = 0 To 35
s(n) = Chr((n + 48) - 7 * (n 9))
Next n

'// Note: First item is 000
n = Num - 1
Block = k ^ 2

For j = 2 To 0 Step -1
M = Int(n / Block)
UnRank = UnRank & s(M)
n = n - M * Block
Block = Block / k
Next j
End Function

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


wrote in message
ups.com...
Hey! Here is the problem...I can't figure out how to make it so every
possible combination of a series of letters (A-Z) and Numbers (0-9) is
displayed I saw someones code to make it possible for three characters
but I am looking to do it with like 10 characters...The code I saw was
this...

Sub comboo()
Dim s(36) As String
For i = 0 To 9
s(i) = Chr(i + 48)
Next
For i = 10 To 36
s(i) = Chr(i + 55)
Next


k = 1
For i = 0 To 35
For j = 0 To 35
For l = 0 To 35
Cells(k, "A").Value = s(i) & s(j) & s(l)
k = k + 1
Next
Next
Next
End Sub

Any ideas? Any help is much appreciated!!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating combinations sweetas01 Excel Discussion (Misc queries) 0 November 9th 07 03:21 AM
creating stacked column/line chart combinations Cori Charts and Charting in Excel 0 July 31st 06 06:17 PM
Creating combinations based on a criteria Maxi[_2_] Excel Programming 6 February 26th 06 01:56 PM
Creating Combinations michaelp Excel Worksheet Functions 1 November 9th 05 10:01 AM
Creating Combinations from Two Lists jlburak Excel Discussion (Misc queries) 3 December 15th 04 11:21 PM


All times are GMT +1. The time now is 06:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"