Thread: Help Please.
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
John Green[_2_] John Green[_2_] is offline
external usenet poster
 
Posts: 58
Default Help Please.

Robert,

If you want to process each cell in your range you can use:

Dim oCell As Range

For Each oCell In My_Range
MsgBox oCell.Address
Next oCell
End Sub

If you want more control over columns and rows you can use:

Dim i As Long
Dim j As Long

With My_Range

For i = 1 To .Rows.Count
For j = 1 To .Columns.Count
MsgBox .Cells(i, j).Address
Next j
Next i

End With

--

John Green - Excel MVP
Sydney
Australia


"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.