+ Reply to Thread
Results 1 to 11 of 11

Help with formula to return the word before third Comma in a string

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Help with formula to return the word before third Comma in a string

    Dear All

    I was wondering whther I can help with the formula which achive te follwoing
    I need to extract the follwoing: Stating from the right to return the word before the 3 Comma in follwong example "Staff" , however it snot alway Staff it coud be Library or Studnet

    U=IT Services,OU=IIII,OU=Staff,DC=xxx,DC=xx,DC=xxxxx

    Any help is appreciate it

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: Help with formula to return the word before third Comma in a string

    If it's only gonna contain Staff, Library or Studnet and only one occurrence of those words then just use

    =IF(ISNUMBER(SEARCH("Staff",A1)),"Staff",IF(ISNUMBER(SEARCH("Library",A1)),"Library",IF(ISNUMBER(SEARCH("Studnet",A1)),"Studnet","NONE")))
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with formula to return the word before third Comma in a string

    Dear Special-K

    Thanks for this, It is only going to be those combinations but onle the text before the 3 comma in the string after OU=

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Help with formula to return the word before third Comma in a string

    Maybe like this?

    =TRIM(MID(SUBSTITUTE(SUBSTITUTE(A1,"=",","),",",REPT(" ",200)),1000,200))

  5. #5
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with formula to return the word before third Comma in a string

    Thak you for tis, but apologies from me , I need the text before the third comma because the format is not always the same i.e. I have something like
    N=Library,DC=xxx,DC=xx,DC=xxx

    which means starting from the right return the text before the third comma until it hits the = sign so in the case above it will be Library but in forst example it will be Staff

  6. #6
    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: Help with formula to return the word before third Comma in a string

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

    v A B
    1 U=IT Services,OU=IIII,OU=Staff,DC=xxx,DC=xx,DC=xxxxx U=IT Services,OU=IIII,OU=Staff
    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

  7. #7
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with formula to return the word before third Comma in a string

    Dear AlKey

    This is great but I need it to return the value Staff in the first case and Users in the second example as the formula you have given me returns th whole string

  8. #8
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with formula to return the word before third Comma in a string

    Just to clarify as I think I ma causing a bit of a confusion
    in the first example
    U=IT Services,OU=IIII,OU=Staff,DC=xxx,DC=xx,DC=xxxxx
    starting from the right to look at the word before the third comma which is Staff and return value Staff
    and in the example
    N=Library,DC=xxx,DC=xx,DC=xxx
    starting from the right look at the word before the third comma and return its value which is Library

    Its always the word immediately before the third comma (starting from the right) after the =

  9. #9
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,923

    Re: Help with formula to return the word before third Comma in a string

    Try again

    =TRIM(LEFT(RIGHT(SUBSTITUTE(SUBSTITUTE(A1,"=",","),",",REPT(" ",200)),1400),200))

  10. #10
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with formula to return the word before third Comma in a string

    Dear Phuocam

    Worked perfectly. Thank you so much for your help

  11. #11
    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: Help with formula to return the word before third Comma in a string

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

+ 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. Formula that inserts quotes before and after comma in a string
    By jaime81 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-11-2014, 05:57 PM
  2. [SOLVED] Find word in text string and return word adjacent to the left
    By eadamquinn in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-06-2014, 03:22 PM
  3. Replies: 2
    Last Post: 08-05-2013, 04:45 PM
  4. [SOLVED] Formula to return a word from string of text
    By kenadams378 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 06-28-2013, 05:17 AM
  5. Formula help on comma separated String data?
    By JGTExcel in forum Excel General
    Replies: 5
    Last Post: 02-10-2012, 01:05 PM
  6. Formula help on comma separated String data?
    By JGTExcel in forum Excel General
    Replies: 1
    Last Post: 02-09-2012, 03:33 AM
  7. how do i concatenate a string and cell formula and use a comma?
    By bob alou in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2006, 11:35 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