excel macro to automatically put rows in alphabetical order

wally32

New Member
Joined
Mar 7, 2011
Messages
29
hi

Hoping someone can possibly help me to create an excel macro for a speadsheet im trying to create.

I am looking to create a spreadsheet where users will be update continually and the information automatically goes in alphabetical order, to save having to go data sort asecnding constantly.

the spreadsheet will constant of 6 columns A-F and row A1 - F1 will be header columns. when user enters the information into the columns and keys enter, i need that particular row to go in alphabetical order based on the information keyed in Column A.

Im quite a newbie at this, and have looked at several other threads but the codes on there do not seem to work or would do what i am looking for.

thanks
 
Hi Weaver

not sure if you are online. from the macro you came up with above, it is now not automatically sorting after the last column being completed. I have followed the same steps we done but to no joy.
it was working fine when we done it couple days ago. Not sure what has gone wrong.

please help

cheers
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I need to do exactly this for columns 1-9 being sorted by column 1 - except blanks ARE a possible valid entry.


Right click the tab of the sheet you have your data in, then choose 'view code' from the menu

Paste the following into the large pane in the centre of the screen (here's where the links might come in handy if you're unsure of what to do)

Code:
 Private Sub Worksheet_Change(ByVal Target As Range)
   If WorksheetFunction.CountA(Cells(Target.Row, 1).Resize(1, 6)) = 6 And Target.Column < 7 Then
        Application.EnableEvents = False
            Range("A1", Cells(Rows.Count, 6).End(xlUp)).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
                xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
                DataOption1:=xlSortNormal
        Application.EnableEvents = True
    End If
End Sub
Now, if you enter a new line of data, once there are 6 completed cells in A - F, the new data table will be sorted. Also, if you change any of the previous records in column A, the data will be resorted.

If blanks are a possible valid entry, we may need to rethink the trigger conditions.

BTW I learned everything I know about macros from this site and from the 'record macro' function, so you're starting in the right place!
 
Upvote 0
I need to do exactly this for columns 1-9 being sorted by column 1 - except blanks ARE a possible valid entry.


How strange, I need exactly the same thing to happen in my spreadsheet. Did you find a solution or can anyone please help us with it? The ideal situation is to fill out as many of the cells as I need along a row by hitting tab to move along then it sorts once i press enter. I will always be entering in column A and B then any one or more of the rest of the columns up to I. There will always be a blank somewhere along the row.

thanks for looking at this and hopefully helping us out.
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top