Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Loop through column backward

Status
Not open for further replies.

pgstein

Programmer
Jul 27, 2005
33
0
0
US
Hi, In VB6, I have found a way to loop through a group of cells, starting with the first cell and going all the way to the last. Is there anyway to do it backwards? i.e. starting with the last and moving towards the front? My code is posted below.
Any imput is appreciated. Thanks alot,
Paul

Dim rall As Range
Dim rcell As Range

Set rall = Range("B1", "B100")

For Each rcell In rall
actual = rcell.Value
Next
 
yes there is but looping is often unnecessary - what are you trying to achieve ?

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
I have a list of data, and I need to found the amount out of tolerance from the beginning and end of it.

I actually just figuered it out, it isn't that hard. I don't know what was going through my head. I just used:

Dim i As Long

For i = 100 To 1 Step -1
actual = Range("B" & i).Value
Next

Thanks
 
If you know i will not be over 100, why dim it as long ?? just use integer...

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
How would i work from the bottom up, with the following code?

lngCntr = Columns(1).Find("").Row - 1

For Each varCell In Range("A1", "A" & lngCntr)
Next
 
Use:

For i = lngCntr to 1 step -1
...
Next i
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top