Solved

Sort in excel vba

Posted on 2014-02-25
1
359 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now