Thread: How to sort
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Abhinandan Abhinandan is offline
external usenet poster
 
Posts: 6
Default How to sort

I have a data range, where I want to sort by Column Q. When I recorded the
macro to sort by column q, below code was generated.

ActiveCell.Cells.Select
ActiveWorkbook.worksheets("images").Sort.SortField s.Clear
ActiveWorkbook.worksheets("images").Sort.SortField s.Add Key:= _
ActiveCell.Offset(0, 16).range("A1:A35018"), SortOn:= _
xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.worksheets("images").Sort
.SetRange ActiveCell.range("A1:Z35018")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Is there a better way of sorting by column than the above code?