• 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.

How can I sort a group of numbers

Is there a way to sort a group of numbers starting with the list say in row 10 and I want to move it to row 1. What's in row 9 to row 2, what's in row 8 put it in row 8 and so on
 

Attachments

  • Data sort bottom to top.xlsx
    9.4 KB · Views: 7
  1. Select A4:F15
  2. Go to Data - Sort.
  3. Uncheck box for "My data has headers"
  4. Use dropdowns to Sort by: column A, On: Values, Order: Oldest to Newest
  5. Hit ok, and you're done.
 
I Luke, My box is already unchecked and I do not have an option for oldest to newest. Only small to large and large to small. Can it be done by code? OR am I missing something? I am using 2013 but have access to 97 and 2010 if I need to switch computers.

Thanks
 
Hi Jack,

Running this macro on the exact workbook you gave me produced the desired results.
Code:
Sub RunSort()
    With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SortFields.Clear
        .SortFields.Add Key:=Range("A4:A15") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
        .SetRange Range("A4:F15")
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub
 
Hey Luke, first and foremost THANK YOU!! How do I go about setting this up to run? Which rows and columns do I start with and do I need to add a button to get it to run?

Thanks
 
Hi Jack,

Not exactly sure what you are asking. The code I posted is for the sample book you gave me. You can run it from the VBE, or from XL from the Macro menu, or press Alt+F8 to get the Run dialogue, or insert any shape/button and assign the macro to it.

If you want to change the range, you'll notice there are only 2 range callouts. The first is the key field (which column are we sorting), and the 2nd is the entire range of data to sort.
 
Back
Top