Solved

Sort in excel vba

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

687 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