Auto Alphabetize

Billyfrap

New Member
Joined
Nov 6, 2014
Messages
4
Hello, I have a document that has the first part populated by a list that starts at U64 and is 6 cells long (Z64).
The list consists of Member Name, Role, Phone #, email address, Emergency Contact and Emergency Contact Phone #.
What I'd like to do is have the list auto alphabetize after the Emergency Contact Phone # is entered.
Is this something that excel can do?
Thanks,
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Right click the sheet name and click "View Code". Paste the code below and go back to the worksheet. What this'll do basically is that each time new data is entered in Column Z(Emergency Contact Phone #), it will auto-sort based on Member Name (Column U)
Code:
<code class="vb keyword">Private</code> <code class="vb keyword">Sub</code> <code class="vb plain">Worksheet_Change(</code><code class="vb keyword">ByVal</code> <code class="vb plain">Target </code><code class="vb keyword">As</code> <code class="vb plain">Range)</code>
<code class="vb keyword">On</code> <code class="vb keyword">Error</code> <code class="vb keyword">Resume</code> <code class="vb keyword">Next</code>
<code class="vb keyword">If</code> <code class="vb keyword">Not</code> <code class="vb plain">Intersect(Target, Range(</code><code class="vb string">"Z:Z"</code><code class="vb plain">)) </code><code class="vb keyword">Is</code> <code class="vb keyword">Nothing</code> <code class="vb keyword">Then</code>
<code class="vb plain">Range(</code><code class="vb string">"U63"</code><code class="vb plain">).Sort Key1:=Range(</code><code class="vb string">"U64"</code><code class="vb plain">), _</code>
<code class="vb plain">Order1:=xlAscending, Header:=xlYes, _</code>
<code class="vb plain">OrderCustom:=1, MatchCase:=</code><code class="vb keyword">False</code><code class="vb plain">, _</code>
<code class="vb plain">Orientation:=xlTopToBottom</code>
<code class="vb keyword">End</code> <code class="vb keyword">If</code>
<code class="vb keyword">End</code> <code class="vb keyword">Sub</code>

Im assuming Emergency Contact Phone # is in column z, and Member Name is in column U. If not, just change Z:Z, U1, U2 to the correct columns.
 
Last edited:
Upvote 0
Try this code, which should work according to your specifications of starting on row 64, going down:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim lastRow As Long

'   Exit if more than one cell updated
    If Target.Count > 1 Then Exit Sub
    
'   Exit if updated cells is blank
    If Target = "" Then Exit Sub

'   Only run if column Z updated after row 64
    If Target.Column = 26 And Target.Row >= 64 Then
'       Find last row in column U with data
        If Range("U65") <> "" Then
            lastRow = Range("U64").End(xlDown).Row
'           Sort U-Z by column U
            Range("U64:Z" & lastRow).Sort Key1:=Range("U64"), Order1:=xlAscending, Header:=xlNo, _
                OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        End If
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,469
Messages
6,160,027
Members
451,611
Latest member
PattiButche

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