# [SOLVED] macro excel automatically sort



## wally32 (Mar 4, 2011)

hi

my first post here. 
im hoping someone will be able to advise on how to creata a macro for a spreadsheet i working on. i want the spreadsheet to automatically sort it itself in alphabetical order. The spreadsheet will contain 6 columns (A to F) with column A being the name of an employer.i want to try and create a macro so that whenever a new row is entered that it will automatically run itself into the order i want it to be, in column A (employer).

not sure if i have fully explained myself or being bit vague but any help would be greatly appreciated

thanks


----------



## Dragoen (Apr 10, 2009)

*Re: macro excel automatically sort*

Hi Wally,

Do you only want Column A to be resorted based upon the new entry or do you want all six columns to resort based on Column A sorting A-Z?


----------



## wally32 (Mar 4, 2011)

*Re: macro excel automatically sort*

thanks for the response dragoen. i would want all six columns to re sort as a result what has been initially input in column A.

are there any good websites detailing how to create a macro program from scratch so i can understand the method behind them?

cheers


----------



## Dragoen (Apr 10, 2009)

*Re: macro excel automatically sort*

Hey Wally,

sorry for the delay. Attached is an example of the macro you wanted. It is set to run off of Ctrl-A. If you right click on the sheet tab name "Sheet 1" and select View Code, the macro is in module 1. All I did was use the built in macro recorder to create the vba code and then edited it to change the range to A1:G1000 which might be excessive for your needs.

In the Sheet1 code area is a test I did to make it run automatically based upon the Worksheet_Change event. But it calls itself as the rows are resorted so that was annoying and ended in an error, so it is commented out.

You can google "Create Excel Macros" and find plenty of good references.

Hope that helps,


----------

