+ Reply to Thread
Results 1 to 15 of 15

If a cell contains a specific word, return pre defined string for that word.

  1. #1
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    If a cell contains a specific word, return pre defined string for that word.

    Hi All,

    I'm a bit stumped.

    What I would like to do is if cell B:B contains the string "one" return "1" in column F or if contains "two" return "2" or "three" return 3 and so on and so on.

    This may have up to 20 specific searches in the one cell.

    Hope this makes sense and many thanx in advance.

    Shane
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    Re: If a cell contains a specific word, return pre defined string for that word.

    sorry...also the formula shown works for 2x searches but can't seem to add more

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: If a cell contains a specific word, return pre defined string for that word.

    You could set up a small table with the words one, two, three etc. in column M, say, and the corresponding numbers in column N, and then you could use this array* formula in F2:

    =IFERROR(SUMPRODUCT(IF(ISNUMBER(SEARCH($M$1:$M$7,B2)),$N$1:$N$7,0)),"")

    *Note that an array formula needs to be committed using the key combination of Ctrl-Shift-Enter (CSE), rather than the usual Enter.

    Copy down as required.

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    Re: If a cell contains a specific word, return pre defined string for that word.

    Thanx for the reply, modified due to headers {=IFERROR(SUMPRODUCT(IF(ISNUMBER(SEARCH($M$2:$M$5,B2)),$N$2:$N$5,0)),"")} but returns 0

    The return is a text string also if that changes anything. What is the ,0 after $N$5 ???

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: If a cell contains a specific word, return pre defined string for that word.

    The zero is for words which do not occur in the text. If none of the words are present, then you could use this variation to return a blank:

    =IFERROR(1/(1/SUMPRODUCT(IF(ISNUMBER(SEARCH($M$2:$M$8,B2)),$N$2:$N$8,0))),"")

    Note, this is still an array formula, so you must use CSE as previously advised.

    My formula returns numbers, but if you want those to be treated as text values you can just add &"" at the end (still use CSE to commit the formula).

    Copy down as required.

    Pete

  6. #6
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    Re: If a cell contains a specific word, return pre defined string for that word.

    Is this what it should be?

    {=IFERROR(1/(1/SUMPRODUCT(IF(ISNUMBER(SEARCH($M$2:$M$5,B2)),$N$2:$N$5,0))),""&"")}

    Returns blank even though B2 contains the string

  7. #7
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    Re: If a cell contains a specific word, return pre defined string for that word.

    Hi All,

    This one is still not solved. Any help greatly appreciated.

  8. #8
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,831

    Re: If a cell contains a specific word, return pre defined string for that word.

    It works for me. Maybe you should attach your latest one that is not working and we can look at it.

  9. #9
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    Re: If a cell contains a specific word, return pre defined string for that word.

    thanx for the reply, please find file attached with the result in column F
    Attached Files Attached Files

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: If a cell contains a specific word, return pre defined string for that word.

    MAy be in F2:
    Please Login or Register  to view this content.
    Quang PT

  11. #11
    Registered User
    Join Date
    06-01-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    15

    Re: If a cell contains a specific word, return pre defined string for that word.

    many thanx ...that worked on a the test spreadsheet

  12. #12
    Registered User
    Join Date
    04-14-2015
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    29

    Re: If a cell contains a specific word, return pre defined string for that word.

    Is there a way to return this in text? So if the strong contains the word one, it should say 'One' and not '1'?

    The exact details of what I am looking for is posted at https://www.excelforum.com/excel-for...ml#post5653350. But this solution would work if I can make it text instead of a number.

  13. #13
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: If a cell contains a specific word, return pre defined string for that word.

    Try:

    =IFERROR(INDEX($N$2:$N$8,MATCH(1,--ISNUMBER(SEARCH($M$2:$M$8,B2)),0)),"")

    Note that if there are multiple occurrences, it will only match the first one in the list. e.g. if you have "one two" it will return the lookup for one, but not two. If would be a bit more complicated to deal with that.

  14. #14
    Registered User
    Join Date
    04-14-2015
    Location
    Chicago, IL
    MS-Off Ver
    2016
    Posts
    29

    Re: If a cell contains a specific word, return pre defined string for that word.

    Thank you for your respionse

  15. #15
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: If a cell contains a specific word, return pre defined string for that word.

    @bakedziti,

    This does not appear to be your thread, as the OP had a username of slamont.

    You should not ask a question in another user's thread - that is referred to as hijacking, and is covered in Rule 04 of the Forum Rules at the top of the page. Instead, you should start your own thread and link back to this one if you think it is relevant.

    Pete

+ 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. [SOLVED] Search specific string of word from a cell
    By Riderboy5877 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-01-2021, 09:36 AM
  2. [SOLVED] Formula Help Pls - Search cell for WORD, return fields from WORD lookup
    By tomski777 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-17-2017, 12:02 AM
  3. [SOLVED] Help with macro to find a specific word and replace the entire cell with the return word.
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-24-2015, 09:40 PM
  4. [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
  5. Replies: 2
    Last Post: 08-05-2013, 04:45 PM
  6. Replies: 8
    Last Post: 10-13-2012, 02:49 PM
  7. Replies: 1
    Last Post: 01-25-2011, 10:50 PM

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