+ Reply to Thread
Results 1 to 4 of 4

create new column with last name

  1. #1
    Registered User
    Join Date
    06-16-2004
    Posts
    6

    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.

  2. #2
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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. #3
    Norman Jones
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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" <[email protected]> wrote in
    > message news:[email protected]...
    >>
    >> 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. #4
    Norman Jones
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1