PDA

View Full Version : Solved: Sort Defined Range



flea333
08-24-2010, 08:26 PM
Why will this code not work, error says the object doesn't support this method.
Define the range:
Set Data = Range(.Cells(DataStart - 1, i), .Cells(Rows.Count, i).End(xlUp))

Now sort the range:
Sheets("AutoList").Data.Sort (Sheets("AutoList").Data.Cells(2, 1))

Bob Phillips
08-25-2010, 12:17 AM
Maybe this would work



Set Data = .Range(.Cells(DataStart - 1, i), .Cells(.Rows.Count, i).End(xlUp))


but without seeing the context, all the code/workbook, it is hard to be sure.

flea333
08-25-2010, 02:38 PM
"Sort method of Range class failed"

mdmackillop
08-25-2010, 02:47 PM
Try

Set Data = Range(.Cells(DataStart - 1, i), .Cells(Rows.Count, i).End(xlUp))
Data.Sort Data(2)