View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default loop through ranges

Try the below. If this does not help post back with an example..and explain
what you are expecting..

Dim rngTemp As Range

Set rngTemp = Range("C5:D10")

For Each varRecord In rngTemp.Rows
For Each cell In varRecord.Cells
MsgBox cell.Address
Next
Next



If this post helps click Yes
---------------
Jacob Skaria


"David" wrote:

I'm suffering from brain freeeze at the moment...

Assuming i've already used Dim and Set, i have something like:

For Each cl in myRng1
Do something dependent on this range
Next cl
For Each cl in myRng2
Do something dependent on this range
Next cl

How could i loop through ranges something like:
for i = 1 to 2
for each cl in (what to use here?)
Do something (function of i)
Next cl
Next i

I can sort the (function of i) bit, it's looping through range names where
i'm stuck
Thanks