Solved

Sort in excel vba

Posted on 2014-02-25
1
362 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 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

Technology Partners: 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

Suggested Solutions

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

734 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