Results 1 to 6 of 6

Thread: Reversing a "First Middle Last" Name to "Last, First Middle" Name Format

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Lightbulb

    Quote Originally Posted by jamilm View Post
    i am curious to learn this. would it be possible Rick to breakdown this formula. what exactly this multple find and countif did?
    Rick's method:

    The countif is counting if there are a number of spaces as far as I can tell.
    Rick's method works with max 3 words - more than 3 words, it fails to reverse proper
    Looks like a simpler version than mine, however, mine works with more than 3 names (or 2 spaces).

    My method is:

    =MID(MASTER!B5&", "&MASTER!B5,FIND("^^",SUBSTITUTE(MASTER!B5," ","^^",LEN(MASTER!B5)-LEN(SUBSTITUTE(MASTER!B5," ",""))))+1,LEN(MASTER!B5)+1)

    B5 is the single sell with format of:
    "First Last"
    "First Middle Last"
    "First Middle1 Middle2 Last"

    note: format for Rick's or my versions MUST have at least one space, ie: 2 words

    It may be complicated, but gets the job done, and the only way I could get it to work proper.


    As for explaining code, the best way to learn is to dissect it yourself, and learn how each function works. That is mainly how I learned programming, computers, driving, drinking and you can guess the rest.

  2. #2
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Rep Power
    0

    Convert to UDF?

    Hello,

    I am enjoying Rick's code for switching first/last to last/first:

    Code:
    =MID(A2&", "&A2,FIND(" ",A2,FIND(" ",A2)+COUNTIF(A2,"* * *"))+1,LEN(A2)+1)
    I use it often in my little database for running golf tournaments. I would like to turn this line into a function in VBA. I have been trying, and trying, but I'm pretty new to VBA, have yet to write my own function successfully, and can't get the code written properly. Any help would be greatly appreciated.

    The way I would like to use the function is to place it in a blank adjacent cell, and write the value to the blank cell rather than changing the original, just as Rick's code does when placed in the spreadsheet.

    Thank You in advance,
    Kevin


    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 06-12-2023 at 01:05 PM.

Similar Threads

  1. VBA Versions of my "Get Field" and "Get Reverse Field" formulas
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 4
    Last Post: 06-02-2017, 06:15 PM
  2. Replies: 5
    Last Post: 04-18-2013, 02:30 AM
  3. Click On link entitled "Web Timeclock"
    By mrmmickle1 in forum Excel Help
    Replies: 0
    Last Post: 01-24-2013, 04:23 AM
  4. Follow-up to "Excel Number Format: Indian Style Comma Separation"
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 2
    Last Post: 04-14-2012, 10:46 PM
  5. Ordinal Suffix (i.e., "st", "nd", "rd" and "th")
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 0
    Last Post: 03-20-2012, 03:46 AM

Tags for this Thread

Posting Permissions

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