Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
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
Lookup in multple worksheets Mike B Excel Worksheet Functions 5 March 4th 09 08:57 AM
Multple criteria dilemma Grant Reid Excel Worksheet Functions 9 July 13th 06 10:17 PM
multple formulas Maya Excel Discussion (Misc queries) 1 June 28th 06 09:07 PM
multple y to one x Daniel Excel Discussion (Misc queries) 0 December 14th 05 05:36 PM
compiling multple worksheets Tom Ogilvy Excel Programming 0 July 12th 03 05:48 PM


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

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

About Us

"It's about Microsoft Excel"