Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Parsing names from one column into 3.

Have several spreadsheets that have the name of people in one column in the
format - lastname, firstname MiddleInitial.

What I need to do is read that info and parse out each piece of info into
it's own column. One thing I am concerned with is some of the names do not
have middle initials.

Thanks,

Kevin Porter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Parsing names from one column into 3.

You can get most of the solution by selecting the column of names and doing
Data=Text to columns and selecting delimited. then select comma as the
delimiter

this should put last names in the original column and everything else in the
adjacent column. Repeat on the adjacent column, but choose space as the
delimiter.

clean up anomalies manually.

--
Regards,
Tom Ogilvy


"Kevin Porter" wrote:

Have several spreadsheets that have the name of people in one column in the
format - lastname, firstname MiddleInitial.

What I need to do is read that info and parse out each piece of info into
it's own column. One thing I am concerned with is some of the names do not
have middle initials.

Thanks,

Kevin Porter

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Parsing names from one column into 3.

Sub qwerty()
For Each r In Selection
s = Split(r.Value, " ")
r.Offset(0, 1).Value = Left(s(0), Len(s(0)) - 1)
r.Offset(0, 2).Value = s(1)
If UBound(s) = 2 Then
r.Offset(0, 3).Value = s(2)
End If
Next
End Sub

--
Gary''s Student - gsnu200739


"Kevin Porter" wrote:

Have several spreadsheets that have the name of people in one column in the
format - lastname, firstname MiddleInitial.

What I need to do is read that info and parse out each piece of info into
it's own column. One thing I am concerned with is some of the names do not
have middle initials.

Thanks,

Kevin Porter

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Parsing names from one column into 3.

What about this modification to your subroutine?

Sub qwerty()
For Each R In Selection
S = Split(Replace(R.Value, ",", ""), " ")
For X = 0 To UBound(S)
R.Offset(0, X + 1).Value = S(X)
Next
Next
End Sub

Rick


"Gary''s Student" wrote in message
...
Sub qwerty()
For Each r In Selection
s = Split(r.Value, " ")
r.Offset(0, 1).Value = Left(s(0), Len(s(0)) - 1)
r.Offset(0, 2).Value = s(1)
If UBound(s) = 2 Then
r.Offset(0, 3).Value = s(2)
End If
Next
End Sub

--
Gary''s Student - gsnu200739


"Kevin Porter" wrote:

Have several spreadsheets that have the name of people in one column in
the
format - lastname, firstname MiddleInitial.

What I need to do is read that info and parse out each piece of info into
it's own column. One thing I am concerned with is some of the names do
not
have middle initials.

Thanks,

Kevin Porter


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Parsing names from one column into 3.

A very nice improvement !
--
Gary''s Student - gsnu200739


"Rick Rothstein (MVP - VB)" wrote:

What about this modification to your subroutine?

Sub qwerty()
For Each R In Selection
S = Split(Replace(R.Value, ",", ""), " ")
For X = 0 To UBound(S)
R.Offset(0, X + 1).Value = S(X)
Next
Next
End Sub

Rick


"Gary''s Student" wrote in message
...
Sub qwerty()
For Each r In Selection
s = Split(r.Value, " ")
r.Offset(0, 1).Value = Left(s(0), Len(s(0)) - 1)
r.Offset(0, 2).Value = s(1)
If UBound(s) = 2 Then
r.Offset(0, 3).Value = s(2)
End If
Next
End Sub

--
Gary''s Student - gsnu200739


"Kevin Porter" wrote:

Have several spreadsheets that have the name of people in one column in
the
format - lastname, firstname MiddleInitial.

What I need to do is read that info and parse out each piece of info into
it's own column. One thing I am concerned with is some of the names do
not
have middle initials.

Thanks,

Kevin Porter





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Parsing names from one column into 3.

On Fri, 24 Aug 2007 09:14:02 -0700, Kevin Porter
wrote:

Have several spreadsheets that have the name of people in one column in the
format - lastname, firstname MiddleInitial.

What I need to do is read that info and parse out each piece of info into
it's own column. One thing I am concerned with is some of the names do not
have middle initials.

Thanks,

Kevin Porter



Data/Text to Columns
Delimited
Select Space and also Select Comma
Select "Treat consecutive delimiters as one
Finish

Given your format above, it should parse correctly even with NMI.

However, if you have multiple last names separated by a space (prior to the
comma), then do the Text-to-Columns in two steps. For step 1, select only the
comma as a delimiter.

For step 2, select column 2, and then use space as a delimiter.


--ron
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
parsing full names in to 3 columns me[_10_] Excel Programming 9 March 11th 06 09:57 PM
Formulas for Parsing Full names jonefer Excel Worksheet Functions 3 February 14th 06 06:28 AM
Parsing a column chulita Excel Worksheet Functions 1 February 21st 05 11:19 PM
TypeLib Information Problem? Pass a Function's parameter names as string for parsing? Ali G Excel Programming 1 December 3rd 04 07:02 PM
Parsing Full Names of varying lenths and parts Dan Excel Programming 1 October 24th 03 06:26 PM


All times are GMT +1. The time now is 07:07 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"