Macro To Sort Column Automatically On Opening An Excel Spreadsheet

One of our readers sent us an email to write a macro that automatically sorts a column when the spreadsheet is opened. Below is the exact email we received:

Hey team,

I need a macro to sort a column when spreadsheet is opened. For example if data is:

a 1 2
c 5 6
b 3 4

When I open the spreadsheet, the data should be sorted on first columns as below:

a 1 2
b 3 4
c 5 6

Your help will be much appreciated.


We analyzed the requirement and realized that this macro enables user to add data at the end and still find everything sorted when spreadsheet is opened. It seems to be very useful and hence we are providing a solution as below.

Note: To find out the detailed steps on how to create, run or edit a macro, you may refer here.

Few Points Worth To Note:

  • While creating the Macro, ensure that name of the macro is kept as “auto_open”
  • Worksheet names is considered to be “Sheet1″
  • Sorting is done on first column and all other columns are rearranged according to first column

Hope you find this solution useful, your suggestions, feedback and comments are always welcome.

  1. I am seeking a macro that identifies errors within a column of email addresses, I wish to sort all data to remove anything that would cause a non deliverable error from my carrier , can you help with a sort macro My ID column is always column J I usually have 50k lines and columns that have various info name address etc. emails that are on J.

    Thanks for your help
    Rickey Thomas

  2. I need to create a macro which will highlight all the changes that has undergone in one sheet and highlight those cells in another sheet-2 which has old data of sheet 1.
    eg: first sheet -1 data is same like sheet-2 data. Now various fields in sheet-1 keeps changing and this change need to reflect in sheet-2 and highlighted with one color.
    Is it possible to create a Macro for the above scenario !!!

  3. There are some drawbacks to using a macro to automatically sort your data. First, since you are using a macro to sort, the operation is essentially “final.” In other words, after the sorting you can’t use Ctrl+Z to undo the operation.

Leave a Reply to Samrat Roy Cancel reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">