Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the fastest way to walk through an Excel Range object backwards?

Tags:

excel

vba

I'm using VBA in the Excel VBE, but c# or vb are fine. The concept should hold true across the languages.

like image 921
GollyJer Avatar asked Oct 14 '22 17:10

GollyJer


1 Answers

Not sure what you mean. You want to go through from the bottom to top, instead of top to bottom?

This should do:

Dim myrange As Range
Set myrange = Range("B3:E10")

Dim row As Integer, col As Integer
For row = myrange.Rows.Count To 1 Step -1
    For col = myrange.Columns.Count To 1 Step -1
        Debug.Print myrange(row, col).Value  
    Next col
Next row
like image 133
BradC Avatar answered Oct 21 '22 07:10

BradC