Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
The following macro is meant to permutate all possible combinations of 10 arrays of numbers. However, I get error messages when I try to run the macro. I suspect it might be because the arrays (1-10) do not all have the same lengths (the lenght of the arrays vary from 2 to 4 variables). However, the errors could be caused by another problem. Does anyone have an idea of how to fix this problem? Thank you very much, Henrik Sub Permutate() With Worksheets("input") arr1 = .Range("D2:F2").Value arr2 = .Range("D3:F3").Value arr3 = .Range("D4:F4").Value arr4 = .Range("D5:G5").Value arr5 = .Range("D6:E6").Value arr6 = .Range("D7:G7").Value arr7 = .Range("D8:E8").Value arr8 = .Range("D9:F9").Value arr9 = .Range("D10:E10").Value arr10 = .Range("D11:E11").Value End With rw = 1 For i = LBound(arr1, 2) To UBound(arr1, 2) For j = LBound(arr2, 2) To UBound(arr2, 2) For k = LBound(arr3, 2) To UBound(arr3, 2) For l = LBound(arr4, 2) To UBound(arr4, 2) For m = LBound(arr5, 2) To UBound(arr5, 2) For n = LBound(arr6, 2) To UBound(arr6, 2) For o = LBound(arr7, 2) To UBound(arr7, 2) For p = LBound(arr8, 2) To UBound(arr8, 2) For q = LBound(arr9, 2) To UBound(arr9, 2) For r = LBound(arr10, 2) To UBound(arr10, 2) With Worksheets("permutation") .Cells(rw, 1) = arr1(1, i) .Cells(rw, 2) = arr2(1, j) .Cells(rw, 3) = arr3(1, k) .Cells(rw, 4) = arr4(1, l) .Cells(rw, 5) = arr5(1, m) .Cells(rw, 6) = arr6(1, n) .Cells(rw, 7) = arr7(1, o) .Cells(rw, 8) = arr8(1, p) .Cells(rw, 9) = arr9(1, q) .Cells(rw, 10) = arr10(1, r) End With rw = rw + 1 Next: Next: Next: Next: Next: Next: Next: Next: Next: Next End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
permutation | Excel Worksheet Functions | |||
Permutation in excel | Excel Worksheet Functions | |||
Permutation in excel | Excel Worksheet Functions | |||
Permutation in excel | Excel Worksheet Functions | |||
Permutation and combination | Excel Discussion (Misc queries) |