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

microsoft excel course - sort column data

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

ResolvedVersion 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:

Counting Non Number Cells (Text)

If you try to use the COUNT FUNCTION =COUNT(Cell range)with a range of cells with numbers and or containing text fields you wil find that that the text cells will be excluded from the the count. If you want to include them try the the COUNTA FUNCTION =COUNTA(Cell range). This counts both text and number cell values.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.