+ Reply to Thread
Results 1 to 6 of 6

Code for Full Name To Seperate into First, Middle, And Last VBA

  1. #1
    Registered User
    Join Date
    04-11-2014
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 2010
    Posts
    8

    Code for Full Name To Seperate into First, Middle, And Last VBA

    I have this formula that I need in every cell in the column.
    The formula Im using is to seperate First Name from Full Name. Im also going to be using this to seperate the Middle Name and the Last Name.
    My formula for the First Name is:
    =TRIM(IF(COUNTIF(A2,"* *"),LEFT(A2,FIND(" ",A2)),""))
    My Middle Name code is:
    =TRIM(SUBSTITUTE(SUBSTITUTE(A2,B2,""),D2,""))
    And My Last Name Code is:
    =TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),LEN(A2)))

    Is there a VBA Code that code could do this for me?
    Or is this a different way to seperate the names from one cell?

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Code for Full Name To Seperate into First, Middle, And Last VBA

    Is your data just space separated?

    If so, try:
    Please Login or Register  to view this content.
    Use as:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    04-11-2014
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 2010
    Posts
    8

    Re: Code for Full Name To Seperate into First, Middle, And Last VBA

    That would work, but I need it so I can just click on a macro. I have a main macro that follows through a lot of different subs. So I am trying to add something to do exactly what that code does, except in a macro so I do not have to type in the formula each time and drag it down the column. I have the Full Name in column A and it needs to seperate it to First Name in column B, Middle Name in column C, and Last Name in column D. Thank you for your help though.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Code for Full Name To Seperate into First, Middle, And Last VBA

    So write it into a Subroutine - something like:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-11-2014
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 2010
    Posts
    8

    Re: Code for Full Name To Seperate into First, Middle, And Last VBA

    Thank you, that works perfectly. I have been looking for something like this for two weeks now.

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Code for Full Name To Seperate into First, Middle, And Last VBA

    Glad it helped. Should have come here first

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Seperate First, Middle and Last name to seperate columns
    By Accusoft in forum Excel General
    Replies: 4
    Last Post: 04-05-2014, 04:51 AM
  2. [SOLVED] Separating the full name into First and Last name (and middle maybe) - is this possible?
    By benyben123 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 09-13-2013, 03:17 PM
  3. [SOLVED] Trying to seperate FULL NAME into FIRST NAME AND LAST NAME columns.
    By joeurda in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-22-2013, 04:36 PM
  4. Replies: 4
    Last Post: 11-17-2012, 03:19 AM
  5. Replies: 2
    Last Post: 07-17-2008, 01:55 PM

Tags for this Thread

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