+ Reply to Thread
Results 1 to 10 of 10

If formula searching for text

  1. #1
    Registered User
    Join Date
    07-27-2021
    Location
    NOTTINGHAM
    MS-Off Ver
    365 2016
    Posts
    3

    Question If formula searching for text

    Hello,
    I have a spreadsheet that takes meal booking data and summarises it in another column.
    The below formula is being used to show the text "Main 1" if it can't find certain words in column c or to leave the text as it if it does find them on our dinner bookings spreadsheet.
    The problem is that blank cells (where no booking has been made) are also showing as main 1 and I need them to remain blank in this instance.
    The formula was done from searching on forums before so may not be the simplest way of doing this.

    =IF(SUMPRODUCT(--(NOT(ISERR(SEARCH({"Home Sandwiches","Margherita","Vegetarian","vegetable","quorn","cauliflower","butternut","ratatouille","Veggie","Cheese & Onion","Chickpea","Cheese & Tomato","Bean burger","Cheesy","Free","Jacket Potato"},C4)))))>0,C4,"Main 1")

    Hope this makes sense and apologies if this is a simple thing and I'm just being daft! Many thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,428

    Re: If formula searching for text

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  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,813

    Re: If formula searching for text

    You could test for C4 being empty, like this:

    =IF(C4="","",IF(SUMPRODUCT(--(NOT(ISERR(SEARCH({"Home Sandwiches","Margherita","Vegetarian","vegetable","quorn","cauliflower","butternut","ratatouille","Veggie","Cheese & Onion","Chickpea","Cheese & Tomato","Bean burger","Cheesy","Free","Jacket Potato"},C4)))))>0,C4,"Main 1") )

    Hope this helps.

    Pete

  4. #4
    Valued Forum Contributor
    Join Date
    05-15-2017
    Location
    US
    MS-Off Ver
    365
    Posts
    901

    Re: If formula searching for text

    You may be able to wrap your logic like this;

    Please Login or Register  to view this content.
    Sample file would help adjust if needed.
    If you find the suggestion or solution helpful, please consider adding reputation to the post.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,359

    Re: If formula searching for text

    Try

    =IF(C4="","",IF(SUMPRODUCT(--(NOT(ISERR(SEARCH($H$2:$H$16,C4)))))>0,C4,"Main 1"))

    H2:H16 contains your meal items and makes it easy to extend/reduce your list
    Or

    defiine a dynamic named range e.g

    Name: Menu_Items

    Refers to: =OFFSET(Sheet1!$H$1,,,COUNTA(Sheet1!$H$1:$H$100),1)


    =IF(C4="","",IF(SUMPRODUCT(--(NOT(ISERR(SEARCH(Menu_Items,C4)))))>0,C4,"Main 1"))

    no formula change required as you can add/remove items from the named range
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-27-2021
    Location
    NOTTINGHAM
    MS-Off Ver
    365 2016
    Posts
    3

    Re: If formula searching for text

    Thanks very much for your help
    Pete_UK that worked perfectly, thamks very much.
    JohnTopley, I'd love to tidy it up more, the list gets bigger every time we change the menu. Unfortunately your formula didn't change it to main 1 if it couldn't find the words in the list?
    I've attached (I hope) a spreadsheet with both formulae on there.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,359

    Re: If formula searching for text

    Use this ...

    =IF($C2="","",IFERROR(INDEX($N$2:$N$50,MATCH($C2,$N$2:$N$50,0)),"Main1"))

    SUMPRODUCT will give wrong results unless the you limit the range to N17 using Named range as per post #3

  8. #8
    Registered User
    Join Date
    07-27-2021
    Location
    NOTTINGHAM
    MS-Off Ver
    365 2016
    Posts
    3

    Re: If formula searching for text

    Perfect, thanks very much

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

    Re: If formula searching for text

    Thanks for the rep.

    If that takes care of your original question, please take a moment to select Thread Tools from the menu above and to the right of your first post in this thread, and mark the thread as SOLVED.

    Pete

  10. #10
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,493

    Re: If formula searching for text

    cell I2 formula , drag down

    HTML Code: 

+ 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. Replies: 2
    Last Post: 03-24-2021, 03:26 AM
  2. Formula to do searching TEXT
    By tao94539 in forum Excel General
    Replies: 4
    Last Post: 04-10-2019, 04:37 PM
  3. Replies: 7
    Last Post: 12-14-2015, 01:20 PM
  4. [SOLVED] Formula for searching multiple text strings
    By Excelcious in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2014, 06:29 PM
  5. Searching if a cell contains a specific piece of text in an IF/OR formula
    By jshaw82 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-23-2013, 02:52 AM
  6. [SOLVED] Searching a string of text using a formula
    By @MeDaveT in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-29-2013, 05:06 PM
  7. conditional formula and searching for text not working
    By OmniBlue in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-22-2012, 04:14 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