Solved

Word 2003, 2007, 2010 - Sorting the SECOND or THIRD word in a series of words

Posted on 2012-03-19
2
233 Views
Last Modified: 2012-04-17
I have a table with the first and last names of people.  I would like to sort by last name --which is the second word inside of the cell.

To further complicate this, some people have a middle initial which I would like to ignore.

How can i sort by last name in a table cell where some people have middle initials?
0
Comment
Question by:brothertruffle880
2 Comments
 
LVL 6

Accepted Solution

by:
Kyle_Davies earned 500 total points
ID: 37737811
0
 
LVL 3

Expert Comment

by:DaFranker
ID: 37737985
With VBA, something like this is rather simple. See this sample Split() function for details on how to parse a single string of text and return an array with the words in it.

If you call for the last element of the string array, you'll have the last word of the line.

For the actual sorting, the easiest would probably be to have a new column containing only the last name, put there by macro or with a UDF. However, it's also possible to have a single macro handle the parsing and sorting all at once, but that also means adding a sorting algorithm to the VBA code, which might not be so simple if you've never done such things before (especially if you want the sorting to happen "inplace", which seems to be the case).
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now