I am trying to write an Excel macro in VBA to take data that is currently sorted based on date and sort it into multiple groupings.
The data set can be thought of as
.
Basically, 4 columns with client information currently sorted by date.
I want to be able to do a multi-tiered sort that is different depending on the section. So, first all the information would be sorted A-Z based on "Section".
Then, for section 1, the information needs to be sorted by subsection (A-Z), then by date (oldest to newest).
But for section 2, the information needs to be sorted just by date (oldest to newest).
For section 3, the information needs to be sorted by client (A-Z), then Subsection (A-Z), then date (oldest to newest).
For section 4, the information needs to be sorted by subsection (A-Z), then client (A-Z), then date (oldest to newest).
With our example data that sort would end up looking like
.
I have tried using the sort function but I am unable to figure out how to define the data. I created a VBA using Columns.sort with keys for each column, but that does not seem to allow me to sort each section differently.



Get & TransformakaPower Query. Group by Section; then you can sort each section according to the applicable rules.