Sorting a table

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
What's the simple way to do this: I have a worksheet called GeneralDB and I have a table called Area there with one single column named Area and I want to sort the table ascending. It can't be very hard to do, right?

The only thing I found by Googling was some overly complicate sort by color etc.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
If i'm getting the question right, i think you can use one of the buttons on the toolbar... select the column you want to sort and press the button that has a letter A above a Z with a downwards pointing arrow to the right hand side... or click on the data menu, then select sort...

Hope that's what you're after? :)
 
Upvote 0
If i'm getting the question right, i think you can use one of the buttons on the toolbar... select the column you want to sort and press the button that has a letter A above a Z with a downwards pointing arrow to the right hand side... or click on the data menu, then select sort...

Hope that's what you're after? :)

Ah, naturally I forgot to tell that I need this done by VBA.
 
Upvote 0
Ah...thought it was too good to be true!!! A simple answer for once!! Sorry... VBA is defo not my forte!!!:laugh:

Yeah, sometimes I forget this forum is about Excel and not Excel VBA, so yes, my fault. I'll post the answer here once I find it.
 
Upvote 0
Why not record a macro whilst sorting manually.

Oh yeah, that's easier. Here's the result:

Code:
    With ActiveWorkbook.Worksheets("GeneralDB").ListObjects("Area")
        .Sort.SortFields.Clear
        .Sort.SortFields.Add Key:=Range("Area[[#All],[Area]]"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    
        With .Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
    End With

I might be able to delete something useless from there, but that seems to work.
 
Upvote 0

Forum statistics

Threads
1,224,504
Messages
6,179,142
Members
452,892
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top