?
Solved

Sort in excel vba

Posted on 2014-02-25
1
Medium Priority
?
364 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

771 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