Solved

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

Posted on 2012-03-19
2
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
Suggested Courses

740 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