Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Loop a range from bottom up

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Loop a range from bottom up

ups

If Cells(r, 1) = DateSerial(2006, 3, 31) Then x = Cells(r, 1).Address




"excelent" skrev:

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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Loop a range from bottom up

For iRow = LastRow To FirstRow Step -1
Debug.Print Cells(iRow, "A")
Next iRow


"Who I Am" wrote:

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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding in row at bottom of range Graham Haughs Excel Programming 4 March 27th 06 08:03 PM
starting from bottom of range instead of top davegb Excel Programming 4 March 8th 06 07:46 PM
how use range to bottom of filled cells? Ian Elliott Excel Worksheet Functions 1 November 14th 05 07:29 PM
Copying formula to the bottom of a range jeremy nickels[_2_] Excel Programming 2 February 28th 05 07:27 PM
How to: Add blank row at bottom of range Brad Clarke Excel Programming 2 November 30th 03 10:20 PM


All times are GMT +1. The time now is 05:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"