Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Extracting First Name from cell with first name and last name

I have searched several posts and am still stumped. I have a first
name and last name in Cell B10 on Sheet1. I want to extract the first
name with no spaces. It is part of a bigger code where I am opening
outlook and making an email. The end result is to use the person's
first name in the saluation. I have all the code to do everything
except that I can't figure out how to grab the first name. Any help
would be greatly appreciated. Thanks in advance.

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Extracting First Name from cell with first name and last name

You probably want this...

=LEFT(A1,FIND(" ",A1&" ")-1)

but be advised that it (and most other solutions) will return the wrong
result for people whose first name has a space in it (such as Mary Ann).

--
Rick (MVP - Excel)



"Matt" wrote in message
...
I have searched several posts and am still stumped. I have a first
name and last name in Cell B10 on Sheet1. I want to extract the first
name with no spaces. It is part of a bigger code where I am opening
outlook and making an email. The end result is to use the person's
first name in the saluation. I have all the code to do everything
except that I can't figure out how to grab the first name. Any help
would be greatly appreciated. Thanks in advance.

Matt


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Extracting First Name from cell with first name and last name

Whoops! You wanted this in VB code, right? Sorry, try this...

FirstName = Split(Range("B10").Value)(0)

--
Rick (MVP - Excel)



"Rick Rothstein" wrote in message
...
You probably want this...

=LEFT(A1,FIND(" ",A1&" ")-1)

but be advised that it (and most other solutions) will return the wrong
result for people whose first name has a space in it (such as Mary Ann).

--
Rick (MVP - Excel)



"Matt" wrote in message
...
I have searched several posts and am still stumped. I have a first
name and last name in Cell B10 on Sheet1. I want to extract the first
name with no spaces. It is part of a bigger code where I am opening
outlook and making an email. The end result is to use the person's
first name in the saluation. I have all the code to do everything
except that I can't figure out how to grab the first name. Any help
would be greatly appreciated. Thanks in advance.

Matt


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Extracting First Name from cell with first name and last name

You are right there is a space. For instance, if the name was United
States, there would be a space in between the name. I ran your vba
text, but it is only bringing in the first letter of the first word -
"U". Am I missing something?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 395
Default Extracting First Name from cell with first name and last name

If your data is well formatted, you might try something like (untested):

left(namestring,find(" ",namestring))

I don't recall offhand, you might have to shorten the length by 1 to not
include the space itself, e.g.
left(namestring,find(" ",namestring)-1)

This only works if you have single first names and single last names. If
your data includes some with prefixes (Dr, Mrs, etc.) or two-word first names
"Carol Anne Carpenter" then this solution isn't likely to be sufficient
without additional data cleaning.

HTH,
Keith

"Matt" wrote:

I have searched several posts and am still stumped. I have a first
name and last name in Cell B10 on Sheet1. I want to extract the first
name with no spaces. It is part of a bigger code where I am opening
outlook and making an email. The end result is to use the person's
first name in the saluation. I have all the code to do everything
except that I can't figure out how to grab the first name. Any help
would be greatly appreciated. Thanks in advance.

Matt
.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Extracting First Name from cell with first name and last name

FirstName = Split(Range("B10").Value)(0)

I ran your vba text, but it is only bringing in the first letter
of the first word - "U". Am I missing something?


That is not possible... unless there was a space between the "U" and the "n"
or unless you Dim'med the FirstName variable like this...

Dim FirstName As String * 1

which I think would be highly unlikely. Show us the code you are using (not
just my one-liner, but the code procedure you have it in).

--
Rick (MVP - Excel)



"Matt" wrote in message
...
You are right there is a space. For instance, if the name was United
States, there would be a space in between the name. I ran your vba
text, but it is only bringing in the first letter of the first word -
"U". Am I missing something?


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
extracting data from one cell to another pat67 Excel Worksheet Functions 8 April 30th 10 11:50 PM
Extracting from a cell Walter H Excel Discussion (Misc queries) 2 January 26th 07 04:13 PM
Extracting data from a cell April Stallings Excel Discussion (Misc queries) 6 July 14th 06 03:10 PM
Extracting hyperlink from a cell giraph Excel Worksheet Functions 1 February 11th 06 06:11 PM
extracting a string from a cell cjsmith22[_3_] Excel Programming 1 November 4th 05 10:23 AM


All times are GMT +1. The time now is 06:50 AM.

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"