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 » Sort a specific column (with header) in descending order
Sort a specific column (with header) in descending order
Resolved · High Priority · Version 365
Sanjhali has attended:
Excel VBA Introduction course
Sort a specific column (with header) in descending order
hi. Cna someone tell me the code to sort a speciifis column in descending order.
The column has a header name.
I tried to use the code by recording the macro but unable to understand that.
RE: Sort a specific column (with header) in descending order
Hi Sanjhali,
Thank you for the forum question.
Yes recording sorting can be difficult to understand. I hope my code below makes sense.
The line:
Worksheets("Sheet1").Sort.SortFields.Clear
makes sure that your data is back to default and prevent other sorting from interfere your sorting.
You will of course need to change my code to your data set. In my code the range("a1:e6") will be sorted by the header (column) in A1.
Sub MySortCode()
Worksheets("Sheet1").Sort.SortFields.Clear
Range("A1:E6").Sort Key1:=Range("A1"), Header:=xlYes
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Wed 16 Feb 2022: Automatically marked as resolved.
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:Removing custom dictionary entriesIf you add something to the custom dictionary in Excel you cannot remove it. The way to get around this is to go into word and remove it there. |