how to auto arrange in alphabetical order-excel sheet

G

Guest

how to auto arrange in alphabetical order-excel sheet after typing names in
random?
 
G

Guest

Let's say we are entering data in column A and we want to alphbetize the
column as entries are made. Try the following macro:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A:A"), Target) Is Nothing Then
Exit Sub
End If
Range("A:A").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

This goes in worksheet code:

1. right-click the tab name at the bottom of the window
2. select View Code - VBE window will open
3. paste the macro in the VBE window and then just close the VBE window
 
G

Gord Dibben

As Dave Peterson has pointed out a few times, this may not be a good idea.

Reason.............perhaps a spelling mistake is made on last entry.

Before user can correct it after hitting ENTER, that entry has been sorted to
who knows where.

A manual Data>Sort might be better after a check for proper entry.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top