View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
excelent excelent is offline
external usenet poster
 
Posts: 695
Default Loop a range from bottom up

test in kolumn A

Sub tst()
For r = 1 To 100
If Cells(r, 1) = DateSerial(2006, 1, 31) Then x = Cells(r, 1).Address
Next
MsgBox ("") & x
End Sub



"Who I Am" skrev:

If I use something like

for each c in range()
next c

the loop will start from the first cell down.

How can I loop from bottom up? Here is the scenario:

1/1/2006
...
...
...
3/31/3006
3/31/2006
3/31/2006

I need the address of the last occurance of 3/31/2006, so I can count
all records from 1/1 to 3/31. If I only loop from top down, the first
occurance of 3/31 isn't want I want.

I will use the start cell address (1/1/2006) and end cell address
(3/31/2006) in another function.

Thanks in advance.