+ Reply to Thread
Results 1 to 7 of 7

Splitting a full name to 2 cells

  1. #1
    Registered User
    Join Date
    07-30-2014
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    21

    Splitting a full name to 2 cells

    Jenny M Giles
    Alen Wood


    Hello. I am trying to build a function that takes a string and breaks apart a cell if it has more than 1 name in it and place the 2nd part of the name into the adjacent column

    Jenny M Giles
    Alen Wood


    Please Login or Register  to view this content.

    I'm stuck with the ActiveCell stuff...I've tried lots of combinations! Please help thanks!!!

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Splitting a full name to 2 cells

    A user defined function can't directly change cells but here is a work around found at http://stackoverflow.com/questions/1...fined-function
    Here is what you need to do:
    Here is your function in a module. Do not forget to declare the Public variable as the Worksheet Event will use them.:
    Please Login or Register  to view this content.
    And here is the Event you need at the worksheet level:
    Please Login or Register  to view this content.
    You'll remark that I don't use the wordcount sub but the INSTR function to find a space in the name parameter.
    Hope this helps
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Forum Contributor
    Join Date
    06-09-2011
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    194

    Re: Splitting a full name to 2 cells

    Hi soranz,

    I probably would not use a fuction, as you need to results - Firstname and lastname, but this depends on your file

    You could use the following Sub instead. I assume the names are in column A (starting in row 2), and you would like to split them to column A and B.
    Please Login or Register  to view this content.
    Let me know if this is what you need.

    Theo
    Remember To Do the Following....
    1. Upload sample files
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Splitting a full name to 2 cells

    Or you can also use formula

    in B1 and pull formula to the right and down.

    =TRIM(MID(SUBSTITUTE(SUBSTITUTE("|"&$A1," ","|",1),"|",REPT(" ",125)),125*COLUMNS($A:A),125))

    Row\Col
    A
    B
    C
    1
    Jenny M Giles Jenny M Giles
    2
    Alen Wood Alen Wood
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Splitting a full name to 2 cells

    It may not be what you want but it works

    Please Login or Register  to view this content.
    Last edited by xladept; 04-08-2015 at 06:07 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  6. #6
    Registered User
    Join Date
    07-30-2014
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    21

    Re: Splitting a full name to 2 cells

    Thank you all! Looks like there are many ways to do it.
    Appreciate the detailed explanations Theo and Leclerc

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Splitting a full name to 2 cells

    Hi Soranz,

    Welcome to the Forum! In Excel it seems that there are always many paths to a solution - and thanks for the rep!

+ 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] conversion of full and partial date into full format
    By sarat47 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-08-2014, 03:43 PM
  2. Replies: 12
    Last Post: 01-30-2013, 07:32 PM
  3. [SOLVED] Fill empty cells with content of full cells above it
    By julia81 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2011, 03:57 PM
  4. Replies: 1
    Last Post: 06-11-2009, 03:57 AM
  5. Counting Full cells
    By Metolius Dad in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-06-2005, 04:06 AM

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