Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default What type of loop?

I am trying to create a loop for the following statement

Set r1 = Range(Cells(4(i), 3), Cells(4(i), 4))
Set r2 = Range(r1, Cells(4(i), 5))
r2.Copy
Cells(5(i+1), 2).PasteSpecial Transpose:=True

the i and i+1 are the values that I want to be changing. My loop needs
to be changing in increments of 4. I have a feeling that I have to do
somekind of loop that would allow me to do the following
for i=1
inew=i+4
i new = i

and the loop continues but when I tried this or anything close to the
for i=1 would take control more than the inew part.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default What type of loop?

didn't test anything, but you can use a step statement with the for loop

for i = 1 to 100 step 4

--


Gary


wrote in message
ups.com...
I am trying to create a loop for the following statement

Set r1 = Range(Cells(4(i), 3), Cells(4(i), 4))
Set r2 = Range(r1, Cells(4(i), 5))
r2.Copy
Cells(5(i+1), 2).PasteSpecial Transpose:=True

the i and i+1 are the values that I want to be changing. My loop needs
to be changing in increments of 4. I have a feeling that I have to do
somekind of loop that would allow me to do the following
for i=1
inew=i+4
i new = i

and the loop continues but when I tried this or anything close to the
for i=1 would take control more than the inew part.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default What type of loop?

On Jul 5, 2:31 pm, wrote:
I am trying to create a loop for the following statement

Set r1 = Range(Cells(4(i), 3), Cells(4(i), 4))
Set r2 = Range(r1, Cells(4(i), 5))
r2.Copy
Cells(5(i+1), 2).PasteSpecial Transpose:=True

the i and i+1 are the values that I want to be changing. My loop needs
to be changing in increments of 4. I have a feeling that I have to do
somekind of loop that would allow me to do the following
for i=1
inew=i+4
i new = i

and the loop continues but when I tried this or anything close to the
for i=1 would take control more than the inew part.


You can use a For...Next loop with a Step.

For example,

For a = 1 to 12 Step 4
Cells(a,1).Select
Next

will make selectoins by stepping up by 4. You can also step in
negative increments as well.

Matt

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default What type of loop?

On Jul 5, 2:31 pm, wrote:
I am trying to create a loop for the following statement

Set r1 = Range(Cells(4(i), 3), Cells(4(i), 4))
Set r2 = Range(r1, Cells(4(i), 5))
r2.Copy
Cells(5(i+1), 2).PasteSpecial Transpose:=True

the i and i+1 are the values that I want to be changing. My loop needs
to be changing in increments of 4. I have a feeling that I have to do
somekind of loop that would allow me to do the following
for i=1
inew=i+4
i new = i

and the loop continues but when I tried this or anything close to the
for i=1 would take control more than the inew part.


You can use a For...Next loop with a Step.

For example,

For a = 1 to 12 Step 4
Cells(a,1).Select
Next

will make selectoins by stepping up by 4. You can also step in
negative increments as well.

Matt

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
Loop type formula - no Macro RD[_2_] Excel Discussion (Misc queries) 2 August 27th 09 02:02 AM
For Each Loop skip using user-defined type? [email protected] Excel Programming 0 November 20th 06 09:08 PM
DoWhile Loop & Type mismatch error oakman[_27_] Excel Programming 4 June 27th 06 11:28 AM
Loop through a User-Defined Type? uf_gator Excel Programming 2 February 21st 06 06:57 PM
Type Error in For Each Worksheet Loop [email protected] Excel Programming 8 January 14th 06 05:37 PM


All times are GMT +1. The time now is 02:43 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"