Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

separate a string in a cell

Status
Not open for further replies.

jflaurin

Technical User
Dec 1, 2007
12
0
0
i have a cell with " Last name, First name " a comma separates the first from last name. How can I extract only the first name ?

I know it's simple to do....but I only had 1 coffee today and can't figure it out :)
 



Hi,

No VBA required, unless you want to macro recoed.

Data > Text to columns.

Choose DELIMITER and COMMA as the delimiter. Step 3, select the Column data format Do not import column (skip)

Alternatively, you can use the LEFT, FIND & LEN functions in a formula in an adjacent column.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Let c be the cell reference, i.e., set c = sheet1.range("g42") or some such.
Then c.value is your name1,name2 thingy.
Code:
n=split(c.value,",")
lstName=n(0)
fstName=n(1)

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top