Microsoft Office 2000/Visual Basic Programmer's Guide |
To sort data in Excel by using VBA, use the Sort method on a range or PivotTable report. You can specify up to three columns on which to sort. Keep in mind that if your data is organized in rows — that is, if the data in the first cell of a row is in some way associated with the data in other cells in that row — you must sort on the entire range or PivotTable report in order to maintain the integrity of row data. To ensure that you're sorting on the entire data range, use the CurrentRegion or UsedRange property to return a range representing the whole block of data.