-2

I have a column in Excel contains season value, let say spring, summer, autumn and winter.

How can I sort this season by current season?

Now it's autumn, therefore the order would be autumn, winter, spring and summer

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
wingkit hui
  • 27
  • 1
  • 5
  • 2
    Does this answer your question? [Code an Excel VBA sort with a custom order and a value containing commas](https://stackoverflow.com/questions/6100944/code-an-excel-vba-sort-with-a-custom-order-and-a-value-containing-commas) or this [Custom order sort](https://stackoverflow.com/questions/52848753/excel-vba-custom-order-sort) – Pᴇʜ Nov 13 '19 at 12:22
  • only partial of it, as the season is dynamic, therefore I need to get the current season and then sort by current season, but I don't know how to get the current season – wingkit hui Nov 13 '19 at 23:37

1 Answers1

1

FYI - You can do this without VBA. If you select the data to be sorted, go to Data -> Sort. Then, in the "Order" box, click the dropdown and click "Custom List...".

Here, type your order in the "List Entries" box, and click "Add".

Then back in the Sort box, choose your column to sort by.

enter image description here

BruceWayne
  • 22,923
  • 15
  • 65
  • 110
  • right now we are using this method, however, I need to write a vba for user so that they don't need to do this step, also current season is autumn but I have to write another one once the season is changed. – wingkit hui Nov 13 '19 at 23:39
  • 1
    @wingkithui turn on the macro recorder and do the above. Then review the code. Perhaps then just use a dictionary or something to store the months/seasons. Also see Peh's links in the comment on your original post. – BruceWayne Nov 14 '19 at 02:57