LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to separate First name and Last Name

Hi Michelle

if you just want to cycle through your records and split them into two
columns then this can be done using the Text to Columns feature on the Data
menu

if you're writing code and need to split the two up then one way is:

dim i as integer
dim firstName as string
dim lastName as string
dim fullName as string

fullName = Range("A1") 'or whatever to get the fullname
i = InStr(fullName, " ") 'returns the number of character that the space
relates to
firstName = left(fullName, i - 1) 'take the left portion of fullname
lastName = right(fullName, len(fullName) - i) 'take the right portion of
fullname

assumes - all names are in the first name / last name structure and that the
full names only have one space in them, hope this helps

Cheers
JulieD




"michelle_ho " wrote in message
...
Suppose in cell D3, the value is "Christine White".

I have two variables, firstName and lastName as String.

How can I separate "Christine White", so that firstName = "Christine"
and lastName = "White"??

Thx a lot!


---
Message posted from http://www.ExcelForum.com/





 
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 two dates from a text string into two separate cells Tacrier Excel Discussion (Misc queries) 3 October 13th 08 08:53 PM
I wish to separate city, state, and zip into 3 separate columns Bob Woolbert Excel Worksheet Functions 1 July 11th 06 05:29 PM
Open Separate Excel Files in Separate Windows JTWood Excel Discussion (Misc queries) 3 May 7th 06 10:18 PM
Save 2 separate data imports in separate worksheets on the same ex Jay Excel Worksheet Functions 1 March 8th 06 01:31 PM
Open Excel files in separate sessions, not just separate windows? Bob at Dexia Design Excel Discussion (Misc queries) 1 October 18th 05 05:46 PM


All times are GMT +1. The time now is 07:37 AM.

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

About Us

"It's about Microsoft Excel"