Forum Discussion

mjkjones's avatar
mjkjones
Copper Contributor
Jan 31, 2019

Automatically sort data HELP!

Hey guys

 

Question 1: 

How do I automatically (without out pressing the sort button) sort data in ascending order?

 

Question 2:

Alot of my values will be 0, and therefore if I sort in ascending order, they will stay at the top of the list. How can I automatically sort, in ascending order, but keep the cells with 0 at the bottom of the column. e.g. in the below example, how do I sort so that Player 1 - 4 remains at the bottom?

 

PLAYER 1.      0

PLAYER 2.      0

PLAYER 3.      0

PLAYER 4.      0

PLAYER 5.      2

PLAYER 6.      10

PLAYER 7.      12

 

Thanks you very much. 

Kind Regards

Matthew

5 Replies

  • Rich99's avatar
    Rich99
    Iron Contributor

    Hi,

    One method would be to apply conditional formatting to your values with zero values a different colour from your other values. Then sort your data using custom sort applying two levels one using colour as a sort and the other values, smallest to largest. See attached images.

     

    Rich

     

     

    • mjkjones's avatar
      mjkjones
      Copper Contributor

      Hi Rich,

       

      The problem is I need to automatically sort the data.

      I don't want to be going into the selection and manually sorting every time. 

       

      Thanks

      Matthew

      • Rich99's avatar
        Rich99
        Iron Contributor

        Matthew,

         

        In that case you will need to write some VBA to achieve what you want. I have attached a simple macro which will be a good starting point for you based on my previous solution but automated. There is a macro in sheet 1 that runs whenever a cell is changed in Column B (rows 1 to 18) that calls a macro (Mymacro) that will reorder your list. You will need to extend the conditional formatting to cover your range as well as change the row reference in the macro.

         

        Rich