Solved

Sort in excel vba

Posted on 2014-02-25
1
360 Views
Last Modified: 2014-02-25
I need to sort my worksheet by 3 different columns. The first 2 have to be ascending and then the last one is descending. I do have headers in row 1 so the sort would need to start in row 2. I need to sort as follows:

Column F - Ascending
Column L - Ascending
Column M - Descending

How can this be written in excel vba?
0
Comment
Question by:Lawrence Salvucci
1 Comment
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 39885763
I'm a fan of the old-style sort:

Sub SortActiveSheet()

    Range("a1").Sort Key1:=Range("f1"), Order1:=xlAscending, _
        Key2:=Range("L1"), Order2:=xlAscending, _
        Key3:=Range("m1"), Order3:=xlDescending, _
        Header:=xlYes

End Sub

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generating a graph via Excel 3 25
Delete texts with font color 16 30
ADD New Entries 7 15
Dynamic Filter ? 4 12
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now