![]() |
Reverse Direction of For-Each-Next?
Hi All - part of the code I'm working on has something like: ' _______________________________ For Each XYZ In Range (Cells(topaddressrow, topaddresscolumn) Cells(bottomaddressrow, bottomaddresscolumn)) My_Var = bla.....gather, sum, combine etc what I'm getting.... bla. Next Range("X5").Value = My_Var ' _______________________________ The contents of My_Var is always the result of the code working fro the top of the range downward to the bottom of the range. It does no matter which way I define the range. My question is: Is there a way to make the For Each statemen work/return data from the bottom up? Thanks for any help! FuzzyDov -- FuzzyDov ----------------------------------------------------------------------- FuzzyDove's Profile: http://www.excelforum.com/member.php...fo&userid=1667 View this thread: http://www.excelforum.com/showthread.php?threadid=31991 |
Reverse Direction of For-Each-Next?
For Counter = Start to Finish *Step -1* Next Counte -- crispb ----------------------------------------------------------------------- crispbd's Profile: http://www.excelforum.com/member.php...fo&userid=1088 View this thread: http://www.excelforum.com/showthread.php?threadid=31991 |
Reverse Direction of For-Each-Next?
For ranges it can be done like this:
Sub test() Dim ABC As Range Dim XYZ As Range Dim L As Long Set ABC = Range(Cells(1, 1), Cells(3, 3)) For L = ABC.Count To 1 Step -1 Set XYZ = ABC(L) MsgBox XYZ.Address Next End Sub HTH. Best wishes Harald "FuzzyDove" skrev i melding ... Hi All - part of the code I'm working on has something like: ' _______________________________ For Each XYZ In Range (Cells(topaddressrow, topaddresscolumn), Cells(bottomaddressrow, bottomaddresscolumn)) My_Var = bla.....gather, sum, combine etc what I'm getting.... bla. Next Range("X5").Value = My_Var ' _______________________________ The contents of My_Var is always the result of the code working from the top of the range downward to the bottom of the range. It does not matter which way I define the range. My question is: Is there a way to make the For Each statement work/return data from the bottom up? Thanks for any help! FuzzyDove -- FuzzyDove ------------------------------------------------------------------------ FuzzyDove's Profile: http://www.excelforum.com/member.php...o&userid=16676 View this thread: http://www.excelforum.com/showthread...hreadid=319919 |
All times are GMT +1. The time now is 05:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com