Hello rd12345,
Here is a macro that will separate the last names and place them in column "B". The names are then sorted in A to Z order. Run the macro by using ALT+F8 to display the Macro Dialog List and select SortByLastName
Sub SortByLastName()
Dim Cell As Range
Dim LastRow As Long
Dim Rng As Range
Dim S As Variant
Dim StartRow As Long
StartRow = 1
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set Rng = Range(Cells(StartRow, "A"), Cells(LastRow, "A"))
For Each Cell In Rng
If Cell.Value <> "" Then
S = Split(Cell.Value, " ")
Cell.Offset(0, 1).Value = S(UBound(S))
End If
Next Cell
Set Rng = Range(Cells(StartRow, "A"), Cells(LastRow, "B"))
Rng.Sort Key1:=Rng.Cells(1, 2), Order1:=xlAscending
End Sub
Adding the Macro
1. Copy the macro above pressing the keys CTRL+C
2. Open your workbook
3. Right Click on any Sheet's tab
4. Left Click on View Code in the pop up menu
5. Press the keys ALT+I to activate the Insert menu
6. Press M to insert a Standard Module
7. Paste the code by pressing the keys CTRL+V
8. Make any custom changes you need to the macro
9. Save the Macro by pressing the keys CTRL+S
Sincerely,
Leith Ross
Bookmarks