Excel VBA Multi Level Sort

This article is an extension of the Sorting with VBA article.   It shows how to sort data on multiple levels with the help of Excel VBA.  There may be a scenario where you want to sort more than one column to lay your data out in a certain way.  This procedure is a lot easier to understand than if you simply started the recorder.  Less code means adapting it can be done quite simply with the changing of a few key variables.   The following is a simple 3 column sort.

Option Explicit
Sub SortMulti() 'Excel VBA procedure to sort on multiple levels.
Dim rng As Range
Set rng=Range("A10:CS" & Range("A65536").End(xlUp).Row)

rng.Sort [D10], xlDescending, [C10], , xlDescending, [B10], xlAscending
End Sub

It is a very simple procedure and this is how it works. Firstly I declare my range, then the first sort, Level 1 if you like is on Column D.  The key to keeping the code succinct is to start the row after the header row.  If the headers are in Row 9 start the sort in row 10.  This is sorted in descending order.  The second level (level2, cell C10) is sorted in descending order and the third level, starting from  B10 is sorted in Ascending order.  

So the code will sort column D, then C then B and the results will reflect this.  I have attached an Excel file to outline this simple VBA procedure.