Increasing a range in a loop

  • Thread starter Thread starter ric
  • Start date Start date
R

ric

Is there a way to increase a range in a loop?

So "A1:Z5" would become "A6:Z10".

Regards

Ric
 
Sub Tester11()
Dim rng As Range, rng1 as Range
Dim i as Long
Set rng = Range("A1:Z5")
For i = 1 To 5
Set rng1 = rng.Offset((i - 1) * 5, 0)
MsgBox rng1.Address
Next

End Sub
 
Something like

Dim myRange As Range
Dim i As Long


Set myRange = Range("A1:Z5")
For i = 1 To 5
Set myRange = myRange.Offset(1, 0)
'...
Next

but you can just as easily set it afetr with

Dim myRange As Range
Dim i As Long

Set myRange = Range("A1:Z5")
For i = 1 To 5
Set myRange = myRange.Offset(1, 0)
'...
Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Cheers bob.

Ric

Bob Phillips said:
Something like

Dim myRange As Range
Dim i As Long


Set myRange = Range("A1:Z5")
For i = 1 To 5
Set myRange = myRange.Offset(1, 0)
'...
Next

but you can just as easily set it afetr with

Dim myRange As Range
Dim i As Long

Set myRange = Range("A1:Z5")
For i = 1 To 5
Set myRange = myRange.Offset(1, 0)
'...
Next

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Cheers Tom.

Ric


Tom Ogilvy said:
Sub Tester11()
Dim rng As Range, rng1 as Range
Dim i as Long
Set rng = Range("A1:Z5")
For i = 1 To 5
Set rng1 = rng.Offset((i - 1) * 5, 0)
MsgBox rng1.Address
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top