Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with multple For/Nexts please
Hello I dont understand for next, im trying to work with a series of
variable all of which increment by a certain number every interation. what im trying to do ---------------------------- make a string consisting of the the contents of the 6th, 7th, 9th, 35th, 37th, 38th, 40th, 41st and 42nd columns or multiples of these columns. Repeat this extraction until the end of the row is reached. This is my code that doesn't work - can someone offer a fixed version please. ====== Dim concat As String For i = 6 To 6000 Step 6 For j = 7 To 6000 Step 7 For k = 9 To 6000 Step 9 For l = 35 To 6000 Step 35 For m = 37 To 6000 Step 37 For n = 38 To 6000 Step 38 For o = 40 To 6000 Step 40 For p = 41 To 6000 Step 41 For q = 42 To 6000 Step 42 concat = concat & Cells(2, i) & " " & Cells(2, j) & " " & Cells(2, k) & " " & Cells(2, l) & " " & Cells(2, m) & " " _ & Cells(2, n) & " " & Cells(2, o) & " " & Cells(2, p) & " " & Cells(2, q) Next i Next j Next k Next l Next m Next n Next o Next p Next q ActiveCell = makes End Sub ===================== T I A, Gary. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with multple For/Nexts please
The root of your problem is the For....Next structure. You need to reverse
the order of the 'Next. statements. i.e. For i = 6 To 6000 Step 6 For j = 7 To 6000 Step 7 For k = 9 To 6000 Step 9 For l = 35 To 6000 Step 35 For m = 37 To 6000 Step 37 For n = 38 To 6000 Step 38 For o = 40 To 6000 Step 40 For p = 41 To 6000 Step 41 For q = 42 To 6000 Step 42 concat = concat & Cells(2, i) & " " & Cells(2, j) & " " _ & Cells(2, k) & " " & Cells(2, l) & " " & Cells(2, m) & " " _ & Cells(2, n) & " " & Cells(2, o) & " " & Cells(2, p) _ & " " & Cells(2, q) Next q Next p Next o Next n Next m Next l Next k Next j Next i However, I am sure sure just what you want to accomplish here. An Excel workbook does not have 6000 columns available, less than 300 actually.Also, your string "concat" is going to grow very large. Can you be more precise as to what you want to do? -- Les Torchia-Wells " wrote: Hello I dont understand for next, im trying to work with a series of variable all of which increment by a certain number every interation. what im trying to do ---------------------------- make a string consisting of the the contents of the 6th, 7th, 9th, 35th, 37th, 38th, 40th, 41st and 42nd columns or multiples of these columns. Repeat this extraction until the end of the row is reached. This is my code that doesn't work - can someone offer a fixed version please. ====== Dim concat As String For i = 6 To 6000 Step 6 For j = 7 To 6000 Step 7 For k = 9 To 6000 Step 9 For l = 35 To 6000 Step 35 For m = 37 To 6000 Step 37 For n = 38 To 6000 Step 38 For o = 40 To 6000 Step 40 For p = 41 To 6000 Step 41 For q = 42 To 6000 Step 42 concat = concat & Cells(2, i) & " " & Cells(2, j) & " " & Cells(2, k) & " " & Cells(2, l) & " " & Cells(2, m) & " " _ & Cells(2, n) & " " & Cells(2, o) & " " & Cells(2, p) & " " & Cells(2, q) Next i Next j Next k Next l Next m Next n Next o Next p Next q ActiveCell = makes End Sub ===================== T I A, Gary. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with multple For/Nexts please
Hello Gary!
The is that the Next instruction must be first for the inner nested next. So the order should be Next q Next p Next n Next m and so on. HTH Joćo Araśjo wrote in message ups.com... Hello I dont understand for next, im trying to work with a series of variable all of which increment by a certain number every interation. what im trying to do ---------------------------- make a string consisting of the the contents of the 6th, 7th, 9th, 35th, 37th, 38th, 40th, 41st and 42nd columns or multiples of these columns. Repeat this extraction until the end of the row is reached. This is my code that doesn't work - can someone offer a fixed version please. ====== Dim concat As String For i = 6 To 6000 Step 6 For j = 7 To 6000 Step 7 For k = 9 To 6000 Step 9 For l = 35 To 6000 Step 35 For m = 37 To 6000 Step 37 For n = 38 To 6000 Step 38 For o = 40 To 6000 Step 40 For p = 41 To 6000 Step 41 For q = 42 To 6000 Step 42 concat = concat & Cells(2, i) & " " & Cells(2, j) & " " & Cells(2, k) & " " & Cells(2, l) & " " & Cells(2, m) & " " _ & Cells(2, n) & " " & Cells(2, o) & " " & Cells(2, p) & " " & Cells(2, q) Next i Next j Next k Next l Next m Next n Next o Next p Next q ActiveCell = makes End Sub ===================== T I A, Gary. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Lookup in multple worksheets | Excel Worksheet Functions | |||
Multple criteria dilemma | Excel Worksheet Functions | |||
multple formulas | Excel Discussion (Misc queries) | |||
multple y to one x | Excel Discussion (Misc queries) | |||
compiling multple worksheets | Excel Programming |