How to sort

A

Abhinandan

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.SortFields.Clear
ActiveWorkbook.worksheets("images").Sort.SortFields.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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Modify Sort Routine to inlcude All Data 2
Sorting Question 5
Undo Macro Action 3
Sort by one column then another. 2
vba dynamic 1
Clear Check Box 2
Pictures not being sorted in VBA 2
VBA 2 Codes 2

Top