98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » microsoft excel course - Sort column data
microsoft excel course - Sort column data
Resolved · Low Priority · Version Standard
Yogesh has attended:
No courses
Sort column data
I want the excel vba statement to sort the data in a column.
I have tried the statement: -
Range("A1").SortSpecial SortOrder = x1Ascending
But now its not working. I get the compile error. Cant find project or library?
Also i dont know which library files are need to be installed.
Please give me the alternate statement for this?
RE: Sort column data
Hi Yogesh,
Thank you for your question.
Range("A1").SortSpecial will sort on the cell A1 only.
1) If the range region is fixed, then type in the region:
e.g. Range("A1:D40").Sort
2) If the range region is flexible, then type in the selection:
e.g.
Selection.CurrentRegion.Select
Selection.Sort Key1:=Range("A1")
3) To sort data by first column in ascending order, I would use the following 2 lines:
Selection.CurrentRegion.Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1
Hope this helps.
Regards,
Katie
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Changing Excel file and worksheet defaultsThe appearance of any new Excel files or any new worksheets that are inserted into a file are controlled by two template files, Book.xlt and Sheet.xlt. |