Menu
Forum
General Car Audio
Subwoofers
Speakers
Amplifiers
Head Units
Car Audio Build Logs
Wiring, Electrical and Installation
Enclosure Design & Construction
Car Audio Classifieds
Home Audio
Off-topic Discussion
The Lounge
What's new
Search forums
Gallery
New media
New comments
Search media
Members
Registered members
Current visitors
Classifieds Member Feedback
SHOP
Shop Head Units
Shop Amplifiers
Shop Speakers
Shop Subwoofers
Shop eBay Car Audio
Log in / Register
Forum
Search
Search titles and first posts only
Search titles only
Search titles and first posts only
Search titles only
Log in / Join
What’s new
Search
Search titles and first posts only
Search titles only
Search titles and first posts only
Search titles only
General Car Audio
Subwoofers
Speakers
Amplifiers
Head Units
Car Audio Build Logs
Wiring, Electrical and Installation
Enclosure Design & Construction
Car Audio Classifieds
Home Audio
Off-topic Discussion
The Lounge
What's new
Search forums
Menu
Reply to thread
Forum
Off-topic Discussion
The Lounge
Combinations
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="sumone" data-source="post: 1164413" data-attributes="member: 551481"><p>aight, I was bored. here's what I was talkin about....</p><p></p><p>you gotta enable macros...</p><p></p><p>first column, putin digits accepted (sep. by spaces) for exmaple:</p><p></p><p>"0 1 2 3 4 5 6 7 8 9"</p><p></p><p>w/o quotes if you wanted stuff from 0-9</p><p></p><p>second column put in number of place values (aka 2 digits, 3 digits, etc.)</p><p></p><p>"5"</p><p></p><p>w/o quotes if you wanted all 5-digit numbers using the numbers 0-9</p><p></p><p>hit run</p><p></p><p>and just so you don't think it's a virus or anything here's the code....I didn't do much error checking cause I don't really care if you put somethin in wrong. you could even use it for any character (doesn't have to be "numbers").</p><p></p><p>if you use big *** numbers it's gonna take a while cause all 5 digit numbers with 10 different numbers are 10^5 permutations = 100 thousand. so if you mess around and put in some huge number &amp; get an overflow...oh well</p><p></p><p>[CODE]Public Sub doIt()</p><p> Dim thesheet As Worksheet</p><p> Dim thebook As Workbook</p><p></p><p> On Error GoTo waserr</p><p></p><p> Set thebook = ActiveWorkbook</p><p> Set thesheet = thebook.ActiveSheet</p><p></p><p> Dim strDigits As String, strNumDigits As String, iNumDigits As Long</p><p> Dim theDigits</p><p></p><p> strDigits = thesheet.Cells(2, 1)</p><p> strNumDigits = thesheet.Cells(2, 2)</p><p> Err.Clear</p><p></p><p> iNumDigits = CLng(strNumDigits)</p><p> If Err.Number &lt;&gt; 0 Then</p><p> GoTo waserr</p><p> End If</p><p></p><p> If strDigits &lt;&gt; "" Then</p><p> Dim d As Long, thePositions, thePositionDigitIndexes</p><p> Dim curNum As String, curIndex As Long</p><p></p><p></p><p> theDigits = Split(strDigits, " ")</p><p> ReDim Preserve theDigits(UBound(theDigits))</p><p> ReDim thePositions(iNumDigits - 1)</p><p> ReDim thePositionDigitIndexes(iNumDigits - 1)</p><p></p><p> For d = 0 To UBound(thePositions)</p><p> thePositions(d) = theDigits(0)</p><p> thePositionDigitIndexes(d) = 0</p><p> Next</p><p></p><p> curIndex = 1</p><p></p><p> curNum = ""</p><p> Dim numTimesToDo As Long</p><p> numTimesToDo = UBound(theDigits) + 1</p><p> For d = 1 To UBound(thePositions)</p><p> numTimesToDo = numTimesToDo * (UBound(theDigits) + 1)</p><p> Next</p><p></p><p> Dim curStuff As Long, rowOffset As Long, columnOffset As Long</p><p> rowOffset = 0</p><p> columnOffset = 0</p><p> For curStuff = 1 To numTimesToDo</p><p> For d = UBound(thePositions) To 0 Step -1</p><p> thePositions(d) = theDigits(thePositionDigitIndexes(d))</p><p> Next</p><p></p><p></p><p> curNum = Join(thePositions, "")</p><p> If curIndex &gt; 65530 Then</p><p> columnOffset = columnOffset + 2</p><p> curIndex = 1</p><p> End If</p><p> thesheet.Cells(curIndex + 2, columnOffset + 1) = curStuff</p><p> thesheet.Cells(curIndex + 2, columnOffset + 2) = curNum</p><p></p><p> If curStuff = numTimesToDo Then</p><p> Exit For</p><p> End If</p><p>'1 2 3 / 3</p><p>'0 0 0 =&gt; 1 1 1</p><p>'0 0 1 =&gt; 1 1 2</p><p>'0 0 2 =&gt; 1 1 3</p><p>'0 0 3 =&gt; asdf 0 1 0</p><p> Dim lastIndex As Long</p><p> 'if last position index = last digit, set it to first digit, &amp; set next position to next digit</p><p></p><p> lastIndex = thePositionDigitIndexes(UBound(thePositionDigitIndexes))</p><p> lastIndex = lastIndex + 1</p><p> thePositionDigitIndexes(UBound(thePositionDigitIndexes)) = lastIndex</p><p> For d = UBound(thePositionDigitIndexes) To 0 Step -1</p><p> Dim thisIndex As Long</p><p> thisIndex = thePositionDigitIndexes(d)</p><p> If thisIndex &gt; UBound(theDigits) Then</p><p> thisIndex = 0</p><p> thePositionDigitIndexes(d - 1) = thePositionDigitIndexes(d - 1) + 1</p><p> thePositionDigitIndexes(d) = thisIndex</p><p> End If</p><p> Next</p><p> curIndex = curIndex + 1</p><p> Next</p><p></p><p> End If</p><p></p><p> GoTo getout</p><p></p><p></p><p>waserr:</p><p> MsgBox Err.Description, vbCritical, "error"</p><p></p><p>getout:</p><p> MsgBox "i'm out this *****"</p><p> Exit Sub</p><p></p><p>End Sub[/CODE]</p><p><a href="http:////applications/core/interface/file/attachment.php?id=112" target="_blank">permutations_stuff.zip</a></p></blockquote><p></p>
[QUOTE="sumone, post: 1164413, member: 551481"] aight, I was bored. here's what I was talkin about.... you gotta enable macros... first column, putin digits accepted (sep. by spaces) for exmaple: "0 1 2 3 4 5 6 7 8 9" w/o quotes if you wanted stuff from 0-9 second column put in number of place values (aka 2 digits, 3 digits, etc.) "5" w/o quotes if you wanted all 5-digit numbers using the numbers 0-9 hit run and just so you don't think it's a virus or anything here's the code....I didn't do much error checking cause I don't really care if you put somethin in wrong. you could even use it for any character (doesn't have to be "numbers"). if you use big *** numbers it's gonna take a while cause all 5 digit numbers with 10 different numbers are 10^5 permutations = 100 thousand. so if you mess around and put in some huge number & get an overflow...oh well [CODE]Public Sub doIt() Dim thesheet As Worksheet Dim thebook As Workbook On Error GoTo waserr Set thebook = ActiveWorkbook Set thesheet = thebook.ActiveSheet Dim strDigits As String, strNumDigits As String, iNumDigits As Long Dim theDigits strDigits = thesheet.Cells(2, 1) strNumDigits = thesheet.Cells(2, 2) Err.Clear iNumDigits = CLng(strNumDigits) If Err.Number <> 0 Then GoTo waserr End If If strDigits <> "" Then Dim d As Long, thePositions, thePositionDigitIndexes Dim curNum As String, curIndex As Long theDigits = Split(strDigits, " ") ReDim Preserve theDigits(UBound(theDigits)) ReDim thePositions(iNumDigits - 1) ReDim thePositionDigitIndexes(iNumDigits - 1) For d = 0 To UBound(thePositions) thePositions(d) = theDigits(0) thePositionDigitIndexes(d) = 0 Next curIndex = 1 curNum = "" Dim numTimesToDo As Long numTimesToDo = UBound(theDigits) + 1 For d = 1 To UBound(thePositions) numTimesToDo = numTimesToDo * (UBound(theDigits) + 1) Next Dim curStuff As Long, rowOffset As Long, columnOffset As Long rowOffset = 0 columnOffset = 0 For curStuff = 1 To numTimesToDo For d = UBound(thePositions) To 0 Step -1 thePositions(d) = theDigits(thePositionDigitIndexes(d)) Next curNum = Join(thePositions, "") If curIndex > 65530 Then columnOffset = columnOffset + 2 curIndex = 1 End If thesheet.Cells(curIndex + 2, columnOffset + 1) = curStuff thesheet.Cells(curIndex + 2, columnOffset + 2) = curNum If curStuff = numTimesToDo Then Exit For End If '1 2 3 / 3 '0 0 0 => 1 1 1 '0 0 1 => 1 1 2 '0 0 2 => 1 1 3 '0 0 3 => asdf 0 1 0 Dim lastIndex As Long 'if last position index = last digit, set it to first digit, & set next position to next digit lastIndex = thePositionDigitIndexes(UBound(thePositionDigitIndexes)) lastIndex = lastIndex + 1 thePositionDigitIndexes(UBound(thePositionDigitIndexes)) = lastIndex For d = UBound(thePositionDigitIndexes) To 0 Step -1 Dim thisIndex As Long thisIndex = thePositionDigitIndexes(d) If thisIndex > UBound(theDigits) Then thisIndex = 0 thePositionDigitIndexes(d - 1) = thePositionDigitIndexes(d - 1) + 1 thePositionDigitIndexes(d) = thisIndex End If Next curIndex = curIndex + 1 Next End If GoTo getout waserr: MsgBox Err.Description, vbCritical, "error" getout: MsgBox "i'm out this *****" Exit Sub End Sub[/CODE] [URL="http:////applications/core/interface/file/attachment.php?id=112"]permutations_stuff.zip[/URL] [/QUOTE]
Insert quotes…
Verification
Post reply
Forum
Off-topic Discussion
The Lounge
Combinations
Top
Menu
What's new
Forum list