Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default Interate backward using "Step"

I want to loop backward through the cells in a sheet, but I don't know how.
My normal configuration for looping forward is as follows:

Dim rngCell As Range
Dim wrkSheet As ThisWorkbook.Sheets("DATA")

For Each rngCell In wrkSheet.Columns(1).UsedRange.Rows
....
....
Next

Can someone please show me how to convert this so that it will "step"
backward from the bottom of the sheet upward? Thanks much in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Interate backward using "Step"

Hi Quartz,

Try something like:


Sub sTester02()
Dim rng As Range
Dim i As Long, j As Long
Dim sh As Worksheet

Set sh = ThisWorkbook.Sheets('"DATA")

j = Cells(Rows.Count, "A").End(xlUp).Row

For i = j To 1 Step -1
'// do something,
Next i

End Sub

---
Regards,
Norman



"quartz" wrote in message
...
I want to loop backward through the cells in a sheet, but I don't know how.
My normal configuration for looping forward is as follows:

Dim rngCell As Range
Dim wrkSheet As ThisWorkbook.Sheets("DATA")

For Each rngCell In wrkSheet.Columns(1).UsedRange.Rows
...
...
Next

Can someone please show me how to convert this so that it will "step"
backward from the bottom of the sheet upward? Thanks much 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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Only step through cells that are "Active" WintonCw Excel Programming 4 May 14th 04 11:32 PM
"Multiple-step operation generated errors" Michael Daly Excel Programming 2 December 22nd 03 09:30 AM


All times are GMT +1. The time now is 01:35 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"