VBA sort array

Panoos64

Well-known Member
Joined
Mar 1, 2014
Messages
890
Hi all, I would like to avoid use any excel native functions and i would like to use vba code so that to sort the range of rows "A9" : "M" and rows down, sorting them by column "B" A:Z (alphabetical)
Thank you all in advance
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi Fluff, the above is a bit complicate for me and usually i use the below code, which i assign it into macro command, using "Record" function. Just i need an advice how to adapt it to any name of sheet. Based on below is for a specific Sheet named "Statement Debtors Ageing"

Thank you in advance


Sub SortbyName()
ActiveWorkbook.Worksheets("Statement Debtors Ageing").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Statement Debtors Ageing").Sort.SortFields.Add Key _
:=Range("B5:B10001"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Statement Debtors Ageing").Sort
.SetRange Range("A4:I10001")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
 
Last edited:
Upvote 0
If you want it to work on the active sheet, then change
Code:
ActiveWorkbook.Worksheets("Statement Debtors Ageing")
to
Code:
ActiveSheet
 
Upvote 0
I express my thanks once again Fluff. long time ago i was assign a macro for each spreadsheet when i wanted to sort the data. Many thanks. Hv a great weekend
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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