code_junkie

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

Nov 13th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. Dim myrange As Range
  2. Set myrange = Range("B3:E10")
  3.  
  4. Dim row As Integer, col As Integer
  5. For row = myrange.Rows.Count To 1 Step -1
  6. For col = myrange.Columns.Count To 1 Step -1
  7. Debug.Print myrange(row, col).Value
  8. Next col
  9. Next row
  10.  
  11. Dim vals As Variant
  12. Dim row As Long, col As Long
  13.  
  14. vals = Range("A1:Z100") ' or whatever
  15. For col = UBound(vals,2) To LBound(vals,2) Step -1
  16. For row = UBound(vals) To LBound(vals) Step -1
  17. DoSomethingInterestingWith vals(row, col)
  18. Next
  19. Next
Add Comment
Please, Sign In to add comment