Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default create new column with last name


Hope someone can help.
I have a list of first, middle initial and last names in one
column(about 200 records). I want to pull the last name out and put it
into a new column so it can sorted by last name.
Can someone offer any guidance?
I appreciate it.


--
bufhal
------------------------------------------------------------------------
bufhal's Profile: http://www.excelforum.com/member.php...o&userid=10702
View this thread: http://www.excelforum.com/showthread...hreadid=517584

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default create new column with last name

Hi Bufhal,

Try something like:

'=============
Public Sub Tester007()
Dim rng As Range
Dim rCell As Range
Dim arr As Variant
Const sSeparator As String = " " '<<==== CHANGE

Set rng = Selection

For Each rCell In rng.Cells
With rCell
arr = Split(.Value, sSeparator)
.Offset(0, 1).Value = arr(UBound(arr))
End With
Next rCell

End Sub
'<<=============

This assumes the names are separated with a space. If the separator differs,
amend the value os the sSeparator variable accordingly.


---
Regards,
Norman


"bufhal" wrote in
message ...

Hope someone can help.
I have a list of first, middle initial and last names in one
column(about 200 records). I want to pull the last name out and put it
into a new column so it can sorted by last name.
Can someone offer any guidance?
I appreciate it.


--
bufhal
------------------------------------------------------------------------
bufhal's Profile:
http://www.excelforum.com/member.php...o&userid=10702
View this thread: http://www.excelforum.com/showthread...hreadid=517584



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default create new column with last name

Hi Bufhal.

Preferable would be:

'=============
Public Sub Tester007A()
Dim rng As Range
Dim rCell As Range
Dim arr As Variant
Const sSeparator As String = " " '<<==== CHANGE

Set rng = Selection

For Each rCell In rng.Cells
With rCell
If Not IsEmpty(.Value) Then
arr = Split(.Value, sSeparator)
.Offset(0, 1).Value = arr(UBound(arr))
End If
End With
Next rCell

End Sub
'<<=============


---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Bufhal,

Try something like:

'=============
Public Sub Tester007()
Dim rng As Range
Dim rCell As Range
Dim arr As Variant
Const sSeparator As String = " " '<<==== CHANGE

Set rng = Selection

For Each rCell In rng.Cells
With rCell
arr = Split(.Value, sSeparator)
.Offset(0, 1).Value = arr(UBound(arr))
End With
Next rCell

End Sub
'<<=============

This assumes the names are separated with a space. If the separator
differs, amend the value os the sSeparator variable accordingly.


---
Regards,
Norman


"bufhal" wrote in
message ...

Hope someone can help.
I have a list of first, middle initial and last names in one
column(about 200 records). I want to pull the last name out and put it
into a new column so it can sorted by last name.
Can someone offer any guidance?
I appreciate it.


--
bufhal
------------------------------------------------------------------------
bufhal's Profile:
http://www.excelforum.com/member.php...o&userid=10702
View this thread:
http://www.excelforum.com/showthread...hreadid=517584





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default create new column with last name

Hi Bufhal,

amend the value os the sSeparator variable accordingly.


Should, of course, read:

amend the value of the sSeparator constant accordingly.

---
Regards,
Norman


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
Column has emails & other stuff. Want to create a column w/ just e Jorge Excel Worksheet Functions 1 January 16th 08 05:56 PM
how do I update a column and create new rows for new column cells Pete Excel Discussion (Misc queries) 1 June 6th 07 02:02 AM
how do I create multiple column width in the same column in excel Vish Excel Discussion (Misc queries) 9 November 3rd 06 11:49 PM
How do I create column headings in Excel in the A, B, C etc column eliannaj Excel Discussion (Misc queries) 2 November 23rd 05 06:48 PM


All times are GMT +1. The time now is 02:55 PM.

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"