+ Reply to Thread
Results 1 to 7 of 7

If a cell contains two specific groups of text, then put a specified text in another cell

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    5

    If a cell contains two specific groups of text, then put a specified text in another cell

    I need a formula so that if it finds two specified groups of text in a cell (say cell A1) then it would put a specified text in another cell (say cell A2).

    For example, the contents of cell A1 is "1RXXXLPXX". Since "1R" and "LP" are in cell A1, I need it to put a specific word in cell A2.

    I know how to make it find just "1R" in cell A1 and put a word in cell A2 - I'm using:

    =IF(ISNUMBER(SEARCH("1R",$C56)),"1R")

    But I don't know how to make it find "1R" AND "LP".



    Any help would be appreciated!!
    Last edited by FDibbins; 10-19-2012 at 06:01 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: If a cell contains two specific groups of text, then put a specified text in another c

    Maybe one way (but I'm sure there are others),

    =IF(SUM(COUNTIF(A1,{"*1R*","*LP*"}))>1,"Both are there","No chance")
    HTH
    Regards, Jeff

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: If a cell contains two specific groups of text, then put a specified text in another c

    Try this one

    =IF(and(ISNUMBER(SEARCH("1R",$C56)),ISNUMBER(SEARCH("LP",$C56))),"1R & LP","")
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: If a cell contains two specific groups of text, then put a specified text in another c

    you could use the following construct:

    =if(AND(ISNUMBER(SEARCH({"*1r*","*lp*"},A1))), "whatever", "whatever else")
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  5. #5
    Registered User
    Join Date
    10-19-2012
    Location
    St. Louis, MO
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: If a cell contains two specific groups of text, then put a specified text in another c

    Awesome, I just tried this one and it does exactly what I want it to do:

    =IF(and(ISNUMBER(SEARCH("1R",$C56)),ISNUMBER(SEARCH("LP",$C56))),"1R LP","")


    Thank you very much!

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: If a cell contains two specific groups of text, then put a specified text in another c

    Also a short one;

    =IF(COUNT(SEARCH({"1R","LP"},$C56))=2,"1R LP","")
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: If a cell contains two specific groups of text, then put a specified text in another c

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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