+ Reply to Thread
Results 1 to 7 of 7

values from range present in string?

Hybrid View

  1. #1
    Registered User
    Join Date
    03-13-2012
    Location
    Deventer, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    64

    Question values from range present in string?

    Hi all,
    I have a problem, obviously..

    I'm searching for a formula which checks if any value from a range of cells (A:A) exists in a long string entered in another cell (B1).

    Would be great if someone could help me (without VBA please).

    Thanks,
    Niels

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: values from range present in string?

    This is an arrayed formula so may slow down your workbook depending on how long your list is. Do not use A:A if possible use like A2:A200

    =IF(MAX(--ISNUMBER(SEARCH($A$1:$A$100,B1)))>0, "Y","N")
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    03-13-2012
    Location
    Deventer, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: values from range present in string?

    Hi ChemistB,
    sorry but it's not working (I did press CSE). It only gives N's, also where it should give Y's.

    See for yourself with attached example which, is my aim, should return a Y instead of N.

    Thanks,
    Niels
    Attached Files Attached Files

  4. #4
    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
    53,048

    Re: values from range present in string?

    The formula you used in C1 is nothing like the formula suggested by Chemist. I tried his formula and it returned Y.

    Your formula...
    =IF(MAX(--ISNUMBER(LOOKUP(A1:A4,B1)))>0,"Y","N")
    His formula...
    =IF(MAX(--ISNUMBER(SEARCH($A$1:$A$100,B1)))>0, "Y","N")
    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

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

    Re: values from range present in string?

    Try this non-array formula:

    =IF(SUMPRODUCT(0+ISNUMBER(SEARCH($A$1:$A$7,$B$1)))>0,"Y","N")

    Enter

    Bonus: Counting:

    =SUMPRODUCT(0+ISNUMBER(SEARCH($A$1:$A$7,$B$1)))

    Quang PT

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: values from range present in string?

    As Ford stated you need to use SEARCH, not LOOKUP. Here is your worksheet with the correct formula and some other examples.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: values from range present in string?

    Give this formula a try:

    =SUM(COUNTIF(B1,"*"&A$1:A$6&"*"))>0

    Confirm with Ctrl+Shift+Enter.
    Last edited by István Hirsch; 01-23-2015 at 12:34 PM.

+ 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: 09-03-2014, 03:37 AM
  2. [SOLVED] present values as percentage of sum total of range
    By Christopher135 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-11-2013, 07:50 PM
  3. [SOLVED] Auto Hiding rows based on range/data present or not present.
    By raze in forum Excel Programming / VBA / Macros
    Replies: 27
    Last Post: 02-10-2013, 11:27 AM
  4. Look Up String In Range; If present, Set next Cell to '1'
    By Snoopy2010 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2010, 10:58 AM
  5. Copy For Cell Values Present and not Formulas Present
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2009, 12:10 PM

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