Splitting Imported "Last,First" Names

G

GAKDEV

I am importing an Excel spreadsheet with where the name column is either an organization or LastName,FirstName. I am able to split off the LastName using Left and Instr functions. How do I get the FirstName out. I keep getting either a partial first name or part of the last name. The LastName and FirstName are variable in length.
 
C

Cheryl Fischer

Mid([FullName], InStr([FullName], ",")+1)

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


GAKDEV said:
I am importing an Excel spreadsheet with where the name column is either
an organization or LastName,FirstName. I am able to split off the LastName
using Left and Instr functions. How do I get the FirstName out. I keep
getting either a partial first name or part of the last name. The LastName
and FirstName are variable in length.
 
J

Joe Fallon

You use Left, Mid and Instr and search for the comma separator value.

Instr tells you the position of the comma.

e.g.
Fallon, Joe

The comma is in postion 7 above.
So the last name is Left(str,7-1)

First Name is Mid(str,7+1)

You replace the 7 with your Instr function that finds the comma.
--
Joe Fallon
Access MVP



GAKDEV said:
I am importing an Excel spreadsheet with where the name column is either
an organization or LastName,FirstName. I am able to split off the LastName
using Left and Instr functions. How do I get the FirstName out. I keep
getting either a partial first name or part of the last name. The LastName
and FirstName are variable in length.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top