+ Reply to Thread
Results 1 to 4 of 4

Test if a cell has specific text in an array

  1. #1
    Registered User
    Join Date
    03-27-2020
    Location
    Canada
    MS-Off Ver
    2013 and 365
    Posts
    23

    Test if a cell has specific text in an array

    Hello

    I cannot find the answer on google because I am not able to google properly.

    Basically, I need a formula to return a 1 or 0 if a cell has text matching any of a few conditions. I am using an array in an IF function to hold the text I want to check for.

    It only works if the text in the cell matches the text that is first in the array, ie, if the array returns {1,0,0,0,0}, but I need it to work if ANY of the array results are true. Sample spreadsheet attached.

    =@IF(A1={"A-X","A-L","A-N","GS/A-N"},1,0) is the formula. It only returns a 1 when A1= A-X. It is frustrating.

    Thanks!
    Attached Files Attached Files

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,731

    Re: Test if a cell has specific text in an array

    Try:

    =IF(OR(A1="A-X",A1="A-L",A1="A-N",A1="GS/A-N"),1,0)
    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 Contributor John Vergara's Avatar
    Join Date
    01-17-2022
    Location
    Colombia
    MS-Off Ver
    365
    Posts
    200

    Re: Test if a cell has specific text in an array

    Hi to both!

    Another options:
    =IF(OR(A1={"A-X","A-L","A-N","GS/A-N"}),1,0)
    =--OR(A1={"A-X","A-L","A-N","GS/A-N"})


    Blessings!

  4. #4
    Registered User
    Join Date
    03-27-2020
    Location
    Canada
    MS-Off Ver
    2013 and 365
    Posts
    23

    Re: Test if a cell has specific text in an array

    Thanks guys for your responses!

    Both of those work!

    I found a slight less calculative intensive formula as well:

    =If(sum(countif(a1,{"*A-L","*A-N","*A-X"}))>0,1,0)

+ 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] test if a specific cell is active on Worksheet_Activate()
    By Nick Vittum in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-13-2020, 11:41 PM
  2. How to write a function to test if a cell contains a specific variable?
    By VAer in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-25-2017, 06:59 PM
  3. [SOLVED] Test if a cell is within a name range and return a text value based on the test
    By DraconR in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-24-2013, 02:46 AM
  4. [SOLVED] Find cells with text that contains a specific character, pass cell value to an array
    By schmidt62 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2012, 09:15 PM
  5. Replies: 4
    Last Post: 11-18-2011, 09:50 AM
  6. Replies: 11
    Last Post: 02-18-2009, 10:49 AM
  7. [SOLVED] logical test, array, text and numbers
    By Dan M. in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-25-2006, 04:00 AM

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