John Joseph
John Joseph

Reputation: 1185

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

Upvotes: 1

Views: 820

Answers (1)

Techie
Techie

Reputation: 181

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

Upvotes: 1

Related Questions