ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to sort (https://www.excelbanter.com/excel-programming/413118-how-sort.html)

Abhinandan

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?


All times are GMT +1. The time now is 12:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com