How to change the index value inside Range Object with For Loop

dmadhup

Board Regular
Joined
Feb 21, 2018
Messages
146
Office Version
  1. 365
Hi,
I have following code:n = 2
For i = 1 To 5 Step 1
quantityArray = Worksheets("Sheet1").Range("O13:S13").Value
n = n + 6
Next

In for loop,
when i=2 then I want to change Range object like Range("O14: S14") and
when i=3 then I want to change Range object like Range("O15: S15") and gradually....


Any help towards this is highly appreciated. Thanks
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
One way:
Code:
[COLOR=#333333]For i = 1 To 5 Step 1[/COLOR]
[COLOR=#333333]    quantityArray = Worksheets("Sheet1").Range("O" & i + 12 & ":S" & i + 12).Value[/COLOR]
[COLOR=#333333]    n = n + 6[/COLOR]
[COLOR=#333333]Next[/COLOR]
 
Upvote 0
How about
Code:
For i = 1 To 5 Step 1
quantityArray = Worksheets("Sheet1").Range("O" & i + 12).Resize(, 5).Value
Next
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,874
Messages
6,127,473
Members
449,384
Latest member
purevega

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top