+ Reply to Thread
Results 1 to 7 of 7

Thread: Names to appear in Abbreviated form

  1. #1
    Registered User
    Join Date
    10-28-2011
    Location
    Delhi
    MS-Off Ver
    Excel 2007
    Posts
    86

    Names to appear in Abbreviated form

    Column A contains names like

    Rahul Kumar Mishra
    Rahul Kumar Vishwakarma
    Sushil Kant Sharma
    Ram Mohan Roy
    Mohandas Karmachand Gandhi
    Jawahar Lal Nehru

    Want to know a formula in Column B to make them appear in abbreviated form like

    RKM
    RKV
    SKS
    RMR
    MKG
    JLN


    Thanks

  2. #2
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,150

    Re: Names to appear in Abbreviated form

    Hello,

    this works for cells with up to three names (two spaces)

    =LEFT(A1,1)&IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))>0,MID(A1,FIND(" ",A1)+1,1),"")&IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))>1,MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,1),"")
    cheers,

  3. #3
    Forum Moderator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    4,330

    Re: Names to appear in Abbreviated form

    Teylyn - just for my learning (i am still a noob at formulae)

    Why do you use a ">1" in the 2nd if function in the above formula?
    What if there were four names, would we have to put an additional if loop to track that?
    Cheers,
    Arlette

    If I helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Valued Forum Contributor
    Join Date
    06-09-2010
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007 and 2010
    Posts
    346

    Re: Names to appear in Abbreviated form

    Hi

    this function will work for any number of names - it takes the first letter from each word

    Select alt+F11 and copy it to your VBA area

    in the worksheet, type =Acronym_maker(A1) to return the first letters of the text in cell A1

    Function Acronym_maker(rng As Range)
        Dim arrNos As Variant
        Dim n As Long 
        txt = ""
        arrNos = Split(rng, " ")
        For n = 0 To UBound(arrNos)
            txt = txt & Left(arrNos(n), 1)
        Next
        Acronym_maker = txt
    End Function

  5. #5
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,150

    Re: Names to appear in Abbreviated form

    Quote Originally Posted by arlu1201 View Post
    Teylyn - just for my learning (i am still a noob at formulae)

    Why do you use a ">1" in the 2nd if function in the above formula?
    What if there were four names, would we have to put an additional if loop to track that?
    As I said, the formula is for up to three names. It counts the spaces in A1. If the count is >1, then there are three names, and the third initial will be extracted.

    If the cell can contain four names, the formula would need to be adjusted to accommodate that.

  6. #6
    Registered User
    Join Date
    10-28-2011
    Location
    Delhi
    MS-Off Ver
    Excel 2007
    Posts
    86

    Re: Names to appear in Abbreviated form

    Quote Originally Posted by teylyn View Post
    Hello,

    this works for cells with up to three names (two spaces)

    =LEFT(A1,1)&IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))>0,MID(A1,FIND(" ",A1)+1,1),"")&IF(LEN(A1)-LEN(SUBSTITUTE(A1," ",""))>1,MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,1),"")
    cheers,
    Hi

    I got this:

    =LEFT(B12,1)&MID(B12,FIND(" ",B12)+1,1)&MID(B12,FIND(" ",B12,FIND(" ",B12)+1)+1,1)

    But I want to use Right( function as well.

    Please suggest.

  7. #7
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,150

    Re: Names to appear in Abbreviated form

    But I want to use Right( function as well.
    Why? It's not required to produce the result. Right() returns the rightmost character(s) of a string. If you want to pull initials from a name, Right() is not the right (!) function.

+ 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.2.0