![]() |
Increasing a range in a loop
Is there a way to increase a range in a loop?
So "A1:Z5" would become "A6:Z10". Regards Ric |
Increasing a range in a loop
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 -- Regards, Tom Ogilvy "ric" wrote in message ... Is there a way to increase a range in a loop? So "A1:Z5" would become "A6:Z10". Regards Ric |
Increasing a range in a loop
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) "ric" wrote in message ... Is there a way to increase a range in a loop? So "A1:Z5" would become "A6:Z10". Regards Ric |
Increasing a range in a loop
Cheers bob.
Ric "Bob Phillips" wrote in message ... 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) "ric" wrote in message ... Is there a way to increase a range in a loop? So "A1:Z5" would become "A6:Z10". Regards Ric |
Increasing a range in a loop
Cheers Tom.
Ric "Tom Ogilvy" wrote in message ... 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 -- Regards, Tom Ogilvy "ric" wrote in message ... Is there a way to increase a range in a loop? So "A1:Z5" would become "A6:Z10". Regards Ric |
All times are GMT +1. The time now is 08:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com