+ Reply to Thread
Results 1 to 25 of 25

Changing Capitalization and Text Order Within a Cell

  1. #1
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Changing Capitalization and Text Order Within a Cell

    I've got a program that stores names one way but I want Excel to display them in another.

    When I import a name from another program, I get the name in this format 'DOE John'. (No single apostrophes. No commas in between, just a space. The last name, obviously is DOE).

    I know the proper () function exists, but is there a function, or combination of functions, that could change 'DOE John' to 'John Doe'? Thanks!

  2. #2
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    try this
    =PROPER(MID(A1,FIND("^",SUBSTITUTE(A1," ","^",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1))&" "&LEFT(A1,FIND(" ",A1)))

  3. #3
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    or
    =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)))

  4. #4
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    try this
    =PROPER(MID(A1,FIND("^",SUBSTITUTE(A1," ","^",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1))&" "&LEFT(A1,FIND(" ",A1)))
    Quote Originally Posted by acerrhod View Post
    or
    =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)))
    Thanks! Any difference between the two?...

  5. #5
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    or
    =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)))
    This one is working fine...

    Quote Originally Posted by acerrhod View Post
    try this
    =PROPER(MID(A1,FIND("^",SUBSTITUTE(A1," ","^",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1))&" "&LEFT(A1,FIND(" ",A1)))
    This one is working weird for me... Somehow 'DOE John' became 'Ohn Doe'

    Thanks! Really helpful!

  6. #6
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    the 2nd one is the simplest method if only the text has Last Name and SINGLE NAME

    the 1st one works for LAST NAME and DOUBLE NAME (corrected formula)
    =PROPER(MID(A1,FIND(" ",SUBSTITUTE(A1," ","^",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,LEN(A1))&" "&LEFT(A1,FIND(" ",A1)))

    Sample A1
    SAMSON Mark Anthony

  7. #7
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    or
    =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)))
    Ok, I just noiced this one changes 'DOE John' to 'John Doe ' (there's a space character after 'Doe'!) Is there any way to get rid of that? Thanks!

  8. #8
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    yes, -1 to the LEFT(A1,FIND(" ",A1)) after Find(" ",A1)-1

    =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)-1))

  9. #9
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    ... =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)-1))
    Thanks!

  10. #10
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    yes, -1 to the LEFT(A1,FIND(" ",A1)) after Find(" ",A1)-1

    =PROPER(RIGHT(A1,FIND(" ",A1))&" "&LEFT(A1,FIND(" ",A1)-1))
    I tried this one out and the result I got from 'DOE John' is 'Ohn Doe' ('D' is gone and there are 2 spaces between last name and first name. Thanks!

  11. #11
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by olives View Post
    I tried this one out and the result I got from 'DOE John' is 'Ohn Doe' ('D' is gone and there are 2 spaces between last name and first name. Thanks!
    acerrhod, could you take another look at this formula?... By the way, can it be adjusted to get rid of any spaces before (!) the last name (EXAMPLE: ' DOE') and any AFTER the last name (EXAMPLE: 'DOE ')... Thanks!

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Changing Capitalization and Text Order Within a Cell

    =proper(right(trim(a1),find(" ",trim(a1)))&" "&left(trim(a1),find(" ",trim(a1))-1))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  13. #13
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by martindwilson View Post
    =proper(right(trim(a1),find(" ",trim(a1)))&" "&left(trim(a1),find(" ",trim(a1))-1))
    Thanks! I'll try it tonight!

  14. #14
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by olives View Post
    Thanks! I'll try it tonight!
    Not bad! Thanks! I've got a few mistakes, but I'll try and post them later with examples Thank you!

  15. #15
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by martindwilson View Post
    =proper(right(trim(a1),find(" ",trim(a1)))&" "&left(trim(a1),find(" ",trim(a1))-1))
    I'm getting a few mistakes when people have two last names or they include their middle names.... Can somebody review this so that the first word - which is always capitalized - is always the last in the result? I'll deal with double last names and middle names on an exception basis, thanks!

  16. #16
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by olives View Post
    ... I've got a few mistakes...
    Here's an example:

    For 'DOE John' I get 'John Doe'

    But for 'STANDARD Joe' I get 'Ndard Joe Standard'...

    With the formula:

    =PROPER(RIGHT(TRIM(A1),FIND(" ",TRIM(A1)))&" "&LEFT(TRIM(A1),FIND(" ",TRIM(A1))-1))

  17. #17
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    can you site sample

  18. #18
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Changing Capitalization and Text Order Within a Cell

    try
    =PROPER(TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",30)),20))&" "&LEFT(TRIM(A1),FIND(" ",TRIM(A1))-1))
    i never actually tested the previous one i just added trim!

  19. #19
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    Hi,

    Is the middle name was initial only i.e. DOE John T.?
    can you site an example

  20. #20
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by martindwilson View Post
    ... i never actually tested the previous one...
    I think it's working! I'll try a few more difficult names later tonight, just in case! Thanks!

  21. #21
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    ... Is the middle name... initial only i.e. DOE John T.? ...
    Hi, acerrhod... To answer your question:

    When a middle name appears it's the full middle name, for example:

    DOE John Henry

    What I'll check tonight is how the formula works with double last names, which are used a lot in Latin America and Spain, for example:

    RODRIGUEZ RIVERA Jose Luis

    In that case (two last names) I'd be ok with losing the 2nd LAST NAME (in the example above I would be ok with the result being, for example, 'Jose Luis Rodriguez'.

    Thanks for the inquiry and the chance to clarify!

  22. #22
    Forum Contributor
    Join Date
    04-23-2013
    Location
    Abu Dhabi United Arab Emirates
    MS-Off Ver
    Excel 2010
    Posts
    178

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by olives View Post
    Hi, acerrhod... To answer your question:

    When a middle name appears it's the full middle name, for example:

    DOE John Henry

    What I'll check tonight is how the formula works with double last names, which are used a lot in Latin America and Spain, for example:

    RODRIGUEZ RIVERA Jose Luis

    In that case (two last names) I'd be ok with losing the 2nd LAST NAME (in the example above I would be ok with the result being, for example, 'Jose Luis Rodriguez'.

    Thanks for the inquiry and the chance to clarify!
    hi,
    try this (is too long formula)
    =TRIM(RIGHT(A1,LEN(A1)-(SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(ROW(INDIRECT("65:90"))),"")))-1)))&" "&PROPER(LEFT(A1,SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(ROW(INDIRECT("65:90"))),"")))-1))

    the only problem to this is has single space in the result text if the Last name is single only i.e. DOE John Henry

  23. #23
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Changing Capitalization and Text Order Within a Cell

    original question
    I get the name in this format 'DOE John'. (No single apostrophes. No commas in between, just a space. The last name, obviously is DOE).
    so now how does
    RODRIGUEZ RIVERA Jose Luis fit that criteria!
    just a waste of peoples efforts if you change your requirements

  24. #24
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by acerrhod View Post
    hi, try this... the only problem to this is has single space in the result text if the Last name is single only i.e. DOE John Henry
    That's nice! It's working pretty cool! And all I have to do is use TRIM to fix the space issue! Thanks!
    Last edited by olives; 06-22-2013 at 03:26 PM.

  25. #25
    Registered User
    Join Date
    02-10-2013
    Location
    PR
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Changing Capitalization and Text Order Within a Cell

    Quote Originally Posted by martindwilson View Post
    ... just a waste of peoples efforts if you change your requirements...
    I apologize... You've been mighty helpful and I didn't mean to change the requirements... I mainly wanted what I posted in the original posting and only later came to realize I had the other situation I hadn't noticed until I started playing with the data ... 99% of the names come in the 'DOE John' format, it was only later that I noticed the two last name issue.... I feel bad, sorry...
    Last edited by olives; 06-13-2013 at 12:32 PM.

+ 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