How do I Loop Through A Sorted Excel Range in VBA in the Order I Sorted It In?

I am using VBA to sort a filtered worksheet in Excel 2010. Visually, the sort works, but when I step through the sorted, filtered range in VBA it appears that the range is still in its original order. For my purposes, this is not desired.

Here is an excerpt of my looping code:

For r = 2 To LastRow
    Set row = ws.Range(r & ":" & r)
    Debug.Print row.Row
Next

Answers


Use autofilter mode=false to clear the filter then try sorting.


Need Your Help

GCM push notifications cause 502 Bad Gateway

android .net service push-notification google-cloud-messaging

I have an .Net windows service that sends GCM push notifications via https://android.googleapis.com/gcm/send.

Which account to use while testing in-app purchase?

cocoa-touch ios ios4 in-app-purchase

I am implementing in-app purchase. Basically, I am making a trial app. So I am a little bit confused and maybe forgetting a step in implementation. While I am testing the app on my device, it's ask...