microsoft excel course - sort column data

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » microsoft excel course - Sort column data

microsoft excel course - Sort column data

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Changing Excel file and worksheet defaults

The 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.

By opening, modifying and saving these templates you can change the default settings for all new files and/or all newly inserted sheets.

Use Book.xlt to make change to defaults for new workbooks; and Sheet.xlt to change defaults for sheets.

If you can't find either of these files on your computer, you can create and save them yourself.

You can do this simply by creating a new workbook with the setting you want to use as your defaults; then saving them with the appropriate name in the XLStart folder. If you are using Office 2003, this is usually found in C:\Program Files\Microsoft Office\Office11\XLStart.

View all Excel hints and tips


Server loaded in 0.08 secs.