View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Knut Knut is offline
external usenet poster
 
Posts: 6
Default Loop with variable

I'm trying to use i as variable to loop through three ranges, with no luck..
what am I doing wrong?

Dim TRange1, TRange2, TRange3 As Range

Set TRange1 = Worksheets("Test").Range("B8:H17")
Set TRange2 = Worksheets("Test").Range("B20:H29")
Set TRange3 = Worksheets("Test").Range("B32:H41")
i = 1
For i = 1 To 5
For Each myCell In TRange(i).Cells
--do sth here
Next
i=i+1
next i

knut