+ Reply to Thread
Results 1 to 17 of 17

find the third space after an ampersand in cell

  1. #1
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    find the third space after an ampersand in cell

    Hey all,

    I have this:
    Please Login or Register  to view this content.
    if no comma before first ampersand, then that means last name is at end of cell, so we take content after third space after the ampersand and place it in front and then place a comma and then take content after ampersand and put directly after comma:
    Please Login or Register  to view this content.
    And then in next column, we do above but instead this time we take content before ampersand and stick it after comma:
    Please Login or Register  to view this content.
    I'm stuck trying to figure out how to get content after third space after ampersand:
    Please Login or Register  to view this content.
    Thanks for response.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,165

    Re: finding the third space after an ampersand in cell

    Hi John,

    If KNUD J & MARIA L HOSTRUP is in A1 then
    Please Login or Register  to view this content.
    returns location of third space.

    hth.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    Yeah but that's not third space after an ampersand. That's third space in cell. How do I find third space after ampersand so I can extract the last name?

  4. #4
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    While this formula pulls the last occurrence:
    Please Login or Register  to view this content.
    I am trying to pull everything after three spaces after ampersand. because the last name might be multiple words.

  5. #5
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: finding the third space after an ampersand in cell

    Do these work for you?
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  6. #6
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: finding the third space after an ampersand in cell

    Taking an assumption of 2 cases from your question :-


    KNUD J & MARIA L HOSTRUP
    HOSTRUP, KNUD J & MARIA L

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Will return
    HOSTRUP, KNUD J
    HOSTRUP, MARIA L

    Given Either Case!

  7. #7
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    Thanks for response.

    It almost works.

    In cases, where there's no ampersand and comma, I would like it just to return length of cell:
    Sarah Ann Little Junior
    would just return
    Sarah Ann Little Junior
    since there's no ampersand and comma.

    Your solution turns it into this:
    Junior,Sarah Ann Little

    Thanks for response.

  8. #8
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    I'm thinking of sticking a condition like this:
    =IF(AND(A20<>",",A20<>"&"),TRUE,FALSE)

    before your recommended condition

    Problem is the formula I have above doesn't work as expected. I'm trying to say if the cell does not contain a comma and ampersand then just return length of cell, otherwise run your condition.
    Last edited by johnmerlino; 11-09-2010 at 11:52 PM.

  9. #9
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: finding the third space after an ampersand in cell

    your conditions are looking for the cell to contain just "&" or "," :-

    =IF(FIND(",",B4&",")=FIND("&",B4&"&"),TRUE,FALSE)

    This avoids a not found error,and can only be true if the string contains neither a , or a &

    combining these :-

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    This might work:
    =IF(AND(ISERROR(FIND(",",A20)),ISERROR(FIND("&",A20))),TRUE,FALSE)

  11. #11
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: finding the third space after an ampersand in cell

    As an alternative a 3 way IF :-

    =CHOOSE(SIGN((FIND(",",B2&",")-FIND("&",B2&"&")))+2,1,2,3)

    giving :-

    Please Login or Register  to view this content.
    And

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    Thanks for the replies.

    Your excel formulas are too complicated for me to understand. You mention that this:
    Please Login or Register  to view this content.
    will return this:
    HOSTRUP, MARIA L

    I'm looking to do:
    =IF(ISERR(FIND("&",A1,1)),"",IF(AND(ISERROR(FIND(",",A1)),IF(ISNUMBER(FIND("&",A1)))),RUN YOUR CODE,LEFT(A1,FIND("&",A1,1)-1)))

    So basically if it doesn't find an ampersand, return blank cell. If it doesn't find comma but finds ampersand, run your code. Otherwise if there's an ampersand and a comma, then run: LEFT(A1,FIND("&",A1,1)-1)))

    I just can't get your code integrating into the above formula, because it's too complicated for me to understand where it begins and ends in regards to how I intend it to work above.

    Thanks for response.

  13. #13
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: finding the third space after an ampersand in cell

    The problem is you keep asking parts of the overall problem, then adding more problems to it!

    The easiest way is to provide a list of all possible cases you have, rather than try to solve each one individually and combine the results, you are quickly going to come up to the nesting limit!

    Otherwise you are just going to keep posting more situations!

  14. #14
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: finding the third space after an ampersand in cell

    Once I fill in "Run your code" with the formula that returns like in your example "HOSTRUP,MARIA L"
    then that would be it.

    This is the only situations that could be:
    =IF(ISERR(FIND("&",A1,1)),"",IF(AND(ISERROR(FIND(",",A1)),IF(ISNUMBER(FIND("&",A1)))),RUN YOUR CODE,LEFT(A1,FIND("&",A1,1)-1)))

    If no ampersand, return empty cell, as shown above, if no comma but ampersand exists, then run your code, as shown above, otherwise that must mean that must mean that there is no ampersand but there is a comma so we just return LEFT(A1,FIND("&",A1,1)-1).
    And that would be it.

    In other words, all i really need is a formula to grab, for example, "HOSTRUP,MARIA L" right in the spot where i say "run your code".
    Last edited by johnmerlino; 11-10-2010 at 01:28 AM.

  15. #15
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: find the third space after an ampersand in cell

    Trying to extract the portion that I need:

    Please Login or Register  to view this content.
    This tells me "The Formula You Typed Contains Errors" but it doesn't highlight anything in particular.

  16. #16
    Forum Contributor
    Join Date
    09-19-2010
    Location
    Philadelphia, PA
    MS-Off Ver
    Excel 2007
    Posts
    140

    The Formula You Typed Contains Errors

    =IF(ISERR(FIND("&",A1,1)),"",IF(AND(ISERROR(FIND(",",A1)),IF(ISNUMBER(FIND("&",A1)))),ERROR OCCURS HERE,LEFT(A1,FIND("&",A1,1)-1)))



    Where I say error occurs here, this is what's there:

    LEFT(B3,FIND(",",B3&",")-1)&","&RIGHT(B3,LEN(B3)-FIND("&",B3&"&")),RIGHT(B3,LEN(B3)-SEARCH("@",SUBSTITUTE(B3," ","@",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))&", "&SUBSTITUTE(RIGHT(B3,LEN(B3)-FIND("&",B3&"&")-1),RIGHT(B3,LEN(B3)-SEARCH("@",SUBSTITUTE(B3," ","@",LEN(B3)-LEN(SUBSTITUTE(B3," ",""))))),""))

    which turns this:
    KNUD J & MARIA L HOSTRUP

    into this:
    HOSTRUP,MARIA L

    All it's supposed to do is if no ampersand, return empty cell, if no comma but ampersand exists, then the code which is containing errors right now and excel isn't telling me what problem is, and if there is no ampersand but there is a comma so we just return LEFT(A1,FIND("&",A1,1)-1).

  17. #17
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: find the third space after an ampersand in cell

    here is the file I did the working in, highlighted in yellow at the right are the final formulas, and to the left highlighted in yellow are the parial formulas used to construct the one formula!
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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