• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sort a 1column table

Belleke

Well-Known Member
Hello,
I am looking for the shortest (fastest) VBA code to sort a one (1) colum table from A to Z.
Thanks.
 
I know, I was just wondering if there is shorter code to sort without
things like
Code:
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
Is there a one liner way or so?
 
So what have you tried? Not much of a challenge if you just ask someone else to do it for you, is it?;)

Joking apart - I doubt you'll get it any shorter. Excel has to know what you want it to do, and there are certain instructions for sorting a column that it's going to need. How will Excel know how to sort the column if you don't tell it the sort method and orientation you want?
 
Those are defaults, so simply:

Code:
    With ActiveSheet.ListObjects(1).Range
        .Sort key1:=.Cells(1), Header:=xlYes
    End With

If you insist on one line, replace the With block as necessary.
 
Back
Top