Thread: Help Please.
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bill Barclift Bill Barclift is offline
external usenet poster
 
Posts: 23
Default Help Please.

Loop through each cell in My_Range:

dim rCell as range

for each rCell in My_Range
'Your code here
debug.print rCell.addresslocal
next rCell


Loop through each cell in My_Range, traverse by colums:

Dim rCell as range
Dim rCol as range

for each rCol in My_Range.columns
for each rCell in rCol.Cells
'Your code here
debug.print rCell.addresslocal
next rCell
next rCol


Loop through each cell in My_Range, traverse by rows:

Dim rCell as range
Dim rRow as range

for each rRow in My_Range.Rows
For each rCell in rRow.cells
'Your code here
debug.print rCell.addresslocal
next rCell
next rRow


Bill Barclift


"Bubu" wrote in message
om...
Hello this is Robert.

I need some help how to loop both by row and by column in the selected
area.

When i select a certain variable range, let's call it My_Range
( yesterday My_Range = b7:b7, today My_Range = c9:f27 tomorrow
whatever )

I want to run i macro, to test for a particular condition each single
cell in My_range.

How do i loop from the first to the last cell, changing row and or
column.



Many Thanks.

Best Regards.

Robert.