Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Pull out lastname

Cell A1 = "John Doe" (without quotes)

In a macro, I have the following:
name = Range("A1").Value

How to I pull out just the last name of the person in the variable name and
place it in the variable, lastname?

Thanks,
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Pull out lastname

Formula wise, =RIGHT(A1,(FIND(" ",A1)-2)). You can work that into a macro if
need be.

"WLMPilot" wrote:

Cell A1 = "John Doe" (without quotes)

In a macro, I have the following:
name = Range("A1").Value

How to I pull out just the last name of the person in the variable name and
place it in the variable, lastname?

Thanks,
Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Pull out lastname



"WLMPilot" wrote:

Cell A1 = "John Doe" (without quotes)

In a macro, I have the following:
name = Range("A1").Value

How to I pull out just the last name of the person in the variable name and
place it in the variable, lastname?

Thanks,
Les

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Pull out lastname

There is no fool-proof way of parsing a field where the first and last names
exist together. There are first names composed of two names (such as Mary
Anne) and last names composed of two name parts (such as Della Rossa, who is
a friend of mine; or da Vinci of Leonardo fame; or de Fermat of mathematical
fame). I can get you the last separated name (whether that is the whole last
name or not is for you to decide)...

LastName = Mid(name, InStrRev(name, " ") + 1)

--
Rick (MVP - Excel)



"WLMPilot" wrote in message
...
Cell A1 = "John Doe" (without quotes)

In a macro, I have the following:
name = Range("A1").Value

How to I pull out just the last name of the person in the variable name
and
place it in the variable, lastname?

Thanks,
Les


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Pull out lastname

"Rick Rothstein" schrieb im Newsbeitrag
...
There is no fool-proof way of parsing a field where the first and last names
exist together. There are first names composed of two names (such as Mary
Anne) and last names composed of two name parts (such as Della Rossa, who is a
friend of mine; or da Vinci of Leonardo fame; or de Fermat of mathematical
fame). I can get you the last separated name (whether that is the whole last
name or not is for you to decide)...

LastName = Mid(name, InStrRev(name, " ") + 1)

--
Rick (MVP - Excel)



Just to add some more examples:
Lois McMaster Bujold
William H. Keith Jr.
A. E. Van Vogt
Lillian Steward Carl
all the above are authors.
BTW, Lois was born as Lois McMaster
and Lillian as Lillian Steward.

Another example: DuPont's full name is
E. I. du Pont de Nemours and Company
named after it's founder Eleuthère Irénée du Pont,
a french immigrant who came from Nemours in
France. (Don't know if it refers to the city or the
duchy).

Helmut.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Pull out lastname

You can use this method to return the last name, no matter how many first
and middle names are listed. This returns the last text separated by a
space.

Sub dj()
Dim lnm
lnm = Split(Range("B2"), " ", -1)
Range("B4") = lnm(UBound(lnm))
End Sub

If the name is in B2 it will put the last name in B4. You can work this
into a loop for a range of names.



"WLMPilot" wrote in message
...
Cell A1 = "John Doe" (without quotes)

In a macro, I have the following:
name = Range("A1").Value

How to I pull out just the last name of the person in the variable name
and
place it in the variable, lastname?

Thanks,
Les



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
separate lastname from firstname enrico via OfficeKB.com Excel Worksheet Functions 3 April 14th 09 06:56 AM
lastname, first name plubeski Excel Worksheet Functions 5 September 23rd 08 08:09 PM
LastName, FirstName covert to FirstName LastName Craig860 Excel Discussion (Misc queries) 4 January 14th 08 09:58 PM
How to change lastname, firstname to firstname lastname in Excel? mert Excel Discussion (Misc queries) 1 January 9th 08 06:06 PM
How to seperate lastname and firstname? kai Excel Programming 4 September 3rd 05 03:46 AM


All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"