Share via

Sort and group and then for each group create a descending order sort

Jose Cerda 0 Reputation points
2026-02-10T20:36:08.2466667+00:00

Good Afternoon,

Do you happen to have VBA code to make a sort in excel, where I first sort by a field which groups together a category, then for each category group I can sort in descending order a quantity column.

Developer technologies | VB
0 comments No comments

1 answer

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 2,690 Reputation points Microsoft External Staff
    2026-02-11T06:39:57.8133333+00:00

    Thank you for reaching out!

    Yes, this can be achieved in Excel using a multi-level sort in VBA.

    The approach is to apply two sort levels:

    1.First, sort by the category column in ascending order. This groups all similar categories together.

    2.Then, apply a second sort on the quantity column in descending order. Excel will automatically sort the quantity values within each category group.

    This method ensures that your data is grouped correctly and that each group is internally sorted from highest to lowest quantity.

     

    Let me know if you need any further help with this. I will be happy to assist.
    If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.