![]() |
Permutation in excel
Hallo everybody! I´ve a vba code now that can generate combinations in excel but when i will com to the end of the rows, that means 65500(or something lik that), I have built in code that order it to cintinue on anothe worksheet and it works but something is wrong. In the first workshee it writes all combinations OK but on the next worksheet it do no work, what is wrong? Do any body can help with sloving this problem? Here is the code: Sub aa() Dim i, j, k, l, m, n, o, rw, summ, summ133, dif rw = 1 For i = 1 To 19 For j = i + 1 To 24 For k = j + 1 To 26 For l = k + 1 To 30 For m = l + 1 To 33 For n = m + 1 To 34 For o = n + 1 To 35 summ = i + j + k + l + m + n + o dif = o - i If ((summ 98) And (summ < 106) And (dif 13)) Then Cells(rw, 1) = i Cells(rw, 2) = j Cells(rw, 3) = k Cells(rw, 4) = l Cells(rw, 5) = m Cells(rw, 6) = n Cells(rw, 7) = o rw = rw + 1 End If If ((summ133 = 133) And (dif 12)) Then Worksheets("Blad2").Cells(rw, 1) = i Worksheets("Blad2").Cells(rw, 1) = j Worksheets("Blad2").Cells(rw, 1) = k Worksheets("Blad2").Cells(rw, 1) = l Worksheets("Blad2").Cells(rw, 1) = m Worksheets("Blad2").Cells(rw, 1) = n Worksheets("Blad2").Cells(rw, 1) = o rw = rw + 1 End If Next o Next n Next m Next l Next k Next j Next i End Su -- Swede ----------------------------------------------------------------------- Sweden's Profile: http://www.excelforum.com/member.php...fo&userid=2732 View this thread: http://www.excelforum.com/showthread.php?threadid=47056 |
Permutation in excel
I see your test on summ133, but not where it is set?
"If ((summ133 = 133) And (dif 12)) Then" If you have a general interest in permutations or combinations see: http://groups.google.com/group/micro...1f529de2aaf685 -- Gary''s Student "Sweden" wrote: Hallo everybody! I´ve a vba code now that can generate combinations in excel but when it will com to the end of the rows, that means 65500(or something like that), I have built in code that order it to cintinue on another worksheet and it works but something is wrong. In the first worksheet it writes all combinations OK but on the next worksheet it do not work, what is wrong? Do any body can help with sloving this problem? Here is the code: Sub aa() Dim i, j, k, l, m, n, o, rw, summ, summ133, dif rw = 1 For i = 1 To 19 For j = i + 1 To 24 For k = j + 1 To 26 For l = k + 1 To 30 For m = l + 1 To 33 For n = m + 1 To 34 For o = n + 1 To 35 summ = i + j + k + l + m + n + o dif = o - i If ((summ 98) And (summ < 106) And (dif 13)) Then Cells(rw, 1) = i Cells(rw, 2) = j Cells(rw, 3) = k Cells(rw, 4) = l Cells(rw, 5) = m Cells(rw, 6) = n Cells(rw, 7) = o rw = rw + 1 End If If ((summ133 = 133) And (dif 12)) Then Worksheets("Blad2").Cells(rw, 1) = i Worksheets("Blad2").Cells(rw, 1) = j Worksheets("Blad2").Cells(rw, 1) = k Worksheets("Blad2").Cells(rw, 1) = l Worksheets("Blad2").Cells(rw, 1) = m Worksheets("Blad2").Cells(rw, 1) = n Worksheets("Blad2").Cells(rw, 1) = o rw = rw + 1 End If Next o Next n Next m Next l Next k Next j Next i End Sub -- Sweden ------------------------------------------------------------------------ Sweden's Profile: http://www.excelforum.com/member.php...o&userid=27322 View this thread: http://www.excelforum.com/showthread...hreadid=470566 |
Permutation in excel
looks like you posted the function code and not the "go to next worksheet" code
can only guess: Blad2 is "next sheet" did not select next sheet - your code as shown has no sheet reference and so will work on "Active" sheet. so teh code tyou use to "go to next sheet" needs to activate/select that sheet. "Sweden" wrote: Hallo everybody! I´ve a vba code now that can generate combinations in excel but when it will com to the end of the rows, that means 65500(or something like that), I have built in code that order it to cintinue on another worksheet and it works but something is wrong. In the first worksheet it writes all combinations OK but on the next worksheet it do not work, what is wrong? Do any body can help with sloving this problem? Here is the code: Sub aa() Dim i, j, k, l, m, n, o, rw, summ, summ133, dif rw = 1 For i = 1 To 19 For j = i + 1 To 24 For k = j + 1 To 26 For l = k + 1 To 30 For m = l + 1 To 33 For n = m + 1 To 34 For o = n + 1 To 35 summ = i + j + k + l + m + n + o dif = o - i If ((summ 98) And (summ < 106) And (dif 13)) Then Cells(rw, 1) = i Cells(rw, 2) = j Cells(rw, 3) = k Cells(rw, 4) = l Cells(rw, 5) = m Cells(rw, 6) = n Cells(rw, 7) = o rw = rw + 1 End If If ((summ133 = 133) And (dif 12)) Then Worksheets("Blad2").Cells(rw, 1) = i Worksheets("Blad2").Cells(rw, 1) = j Worksheets("Blad2").Cells(rw, 1) = k Worksheets("Blad2").Cells(rw, 1) = l Worksheets("Blad2").Cells(rw, 1) = m Worksheets("Blad2").Cells(rw, 1) = n Worksheets("Blad2").Cells(rw, 1) = o rw = rw + 1 End If Next o Next n Next m Next l Next k Next j Next i End Sub -- Sweden ------------------------------------------------------------------------ Sweden's Profile: http://www.excelforum.com/member.php...o&userid=27322 View this thread: http://www.excelforum.com/showthread...hreadid=470566 |
All times are GMT +1. The time now is 02:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com