Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Sweden
 
Posts: n/a
Default Permutation in excel


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 13)) 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=470568

  #2   Report Post  
Conrad Carlberg
 
Posts: n/a
Default

It appears that on the worksheet named Blad2 you're repeatedly overwriting
the values that you want -- your code is not incrementing the target row.

--
C^2
Conrad Carlberg

Excel Sales Forecasting for Dummies, Wiley, 2005


"Sweden" wrote in
message ...

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 13)) 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=470568



  #3   Report Post  
Conrad Carlberg
 
Posts: n/a
Default

Or, for that matter, the target column.

--
C^2
Conrad Carlberg

Excel Sales Forecasting for Dummies, Wiley, 2005


"Conrad Carlberg" wrote in message
nk.net...
It appears that on the worksheet named Blad2 you're repeatedly overwriting
the values that you want -- your code is not incrementing the target row.

--
C^2
Conrad Carlberg

Excel Sales Forecasting for Dummies, Wiley, 2005


"Sweden" wrote in
message ...

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 13)) 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=470568





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
"Group" function very slow with Excel 2003 :( ... While very quick with Excel2000 :O) Alain79 Excel Discussion (Misc queries) 4 June 14th 05 07:34 AM
Stop Excel Rounding Dates leinad512 Excel Discussion (Misc queries) 1 April 20th 05 04:19 PM
Hints And Tips For New Posters In The Excel Newsgroups Gary Brown Excel Worksheet Functions 0 April 15th 05 05:47 PM
Excel error - Startup (and Acrobat PDFMaker) gxdata Setting up and Configuration of Excel 0 February 4th 05 03:44 AM
Excel 2002 and 2000 co-install. Control Which Starts ? cnuk Excel Discussion (Misc queries) 2 January 17th 05 08:07 PM


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

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

About Us

"It's about Microsoft Excel"